# Objective-C

Getting started with the what3words Objective-C API wrapper.

Topics: Objective-C, Mobile App, Server and Scripting

Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)

Source: https://developer.what3words.com/tutorial/objective-c

Updated: 2026-11-27

The Objective-C wrapper is useful for Objective-C developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Objective-C applications, without the hassle of having to manage the low level API calls themselves.

Full sample apps for the wrapper can be found in our Github repo

[iOS Sample Apps](https://github.com/what3words/w3w-swift-samples)

## 1. Get API key

You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).

## 2. Installation

You can install the [what3Words API V3 Objective-C Wrapper](https://github.com/what3words/w3w-objectivec-wrapper) into your project using CocoaPods, or Carthage (see the package manager code below).

Find out more on this repository

[Objective-C Wrapper](https://github.com/what3words/w3w-objectivec-wrapper)

**Objective-C**

```objective-c
platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
    pod 'what3words', :git => 'https://github.com/what3words/w3w-objectivec-wrapper.git'
end
```

Carthage:

**Objective-C**

```objective-c
github "what3words/w3w-objectivec-wrapper"
```

For manual installation, `Drop the [W3wGeocoder.m](https://github.com/what3words/w3w-objectivec-wrapper/blob/master/Sources/W3wGeocoder.m) and [W3wGeocoder.h](https://github.com/what3words/w3w-objectivec-wrapper/blob/master/Sources/W3wGeocoder.h) file into your project.`

## 3. Setup

Use these header files:

**Objective-C**

```objective-c
#import "W3wGeocoder.h"
#import <CoreLocation/CoreLocation.h>
```

Or, if you are using Carthage:

**Objective-C**

```objective-c
#import <what3words/what3words.h>
#import <CoreLocation/CoreLocation.h>
```

## 4. Initialise

First create a W3wGeocoder object:

**Objective-C**

```objective-c
W3wGeocoder *api = [[W3wGeocoder alloc] initWithApiKey:@"<Your Secret Key>"];
```

## 5. Usage

### Convert to what3words address

This function converts coordinates (expressed as latitude and longitude) to a what3words address. It takes the latitude and longitude as a [CLLocationCoordinate2D](https://developer.apple.com/documentation/corelocation/cllocationcoordinate2d?language=swift) object.

More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).

Find the words for (`51.520847, -0.195521`):

**Objective-C**

```objective-c
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(51.520847, -0.195521);
  
[api convertTo3wa:coordinates completion:^(W3wPlace *place, W3wError *error)
    {
    NSLog(@"%@", place.words);
    }];
```

### Convert to coordinates

This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.

It takes the words parameter as a string of a what3words `'table.book.chair'`

More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).

Find the words for `///filled.count.soap`:

**Objective-C**

```objective-c
[api convertToCoordinates:@"filled.count.soap" format:JSON completion:^(W3wPlace *place, W3wError *error)
    {
    NSLog(@"Coordinates are: (%f, %f)", place.coordinates.latitude, place.coordinates.longitude);
    }];
```

### AutoSuggest

When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.

This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.

Optionally, clipping can narrow down the possibilities, and limit results to:

- One or more countries
- A geographic area (a circle, box or polygon)

This dramatically improves results, so we recommend that you use clipping if possible.

To improve results even further, set the `Focus` to user’s current location.  This returns an `Array?` of `W3wSuggestion` objects.

More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).

**Code example** Simple basic call:

**Objective-C**

```objective-c
[api autosuggest:@"geschaft.planter.carciofi" completion:^(NSArray *suggestions, W3wError *error)
    {
    W3wSuggestion *first_match = suggestions[0];
    NSLog(@"%@", first_match.words);
    }];
```

**Code example** AutoSuggest, clipping the results returned to Germany:

**Objective-C**

```objective-c
[api autosuggest:@"geschaft.planter.carciofi" parameters:@[[AutoSuggestOption clipToCountry:@"DE"], [AutoSuggestOption numberResults:4]] completion:^(NSArray *suggestions, W3wError *error)
   {
   W3wSuggestion *first_match = suggestions[0];
   NSLog(@"%@", first_match.words);
   }];
```

**Code example** Focus on (51.4243877,-0.34745)

**Objective-C**

```objective-c
[api autosuggest:@"fun.with.code" parameters:@[[AutoSuggestOption focus:CLLocationCoordinate2DMake(51.4243877, -0.3474524)], [AutoSuggestOption numberResults:6]] completion:^(NSArray *suggestions, W3wError *error)
    {
    W3wSuggestion *first_match = suggestions[0];
    NSLog(@"%@", first_match.words);
    }];
```

**Code example** AutoSuggest, with Generic Voice input type.

**Objective-C**

```objective-c
[api autosuggest:@"fun with code" parameters:@[[AutoSuggestOption fallBackLanguage:@"EN"], [AutoSuggestOption inputType:GENERIC_VOICE]] completion:^(NSArray *suggestions, W3wError *error)
    {
    W3wSuggestion *first_match = suggestions[0];
    NSLog(@"%@", first_match.words);
    }];
```

### Grid section

Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.

The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.

More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).

Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:

**Objective-C**

```objective-c
[api gridSection:52.208867 west_lng:0.117540 north_lat:52.207988 east_lng:0.116126 format:JSON completion:^(NSArray *grid, W3wError *error)
    {
    W3wLine *first_line = grid[0];
    NSLog(@"First line goes from (%.5f,%.5f) to (%.5f,%.5f)", first_line.start.latitude, first_line.start.longitude, first_line.end.latitude, first_line.end.longitude);
    }];
```

### Available languages

This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.

More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).

**Objective-C**

```objective-c
[api availableLanguages:^(NSArray *languages, W3wError *error)
    {
    W3wLanguage *language = languages[0];
    NSLog(@"First language returned: %@", language.name);
    }];
```

### Handling errors

All functions call the completion block with error as the second parameter. Be sure to check it for possible problems.

**Objective-C**

```objective-c
[api convertToCoordinates:@"aaaa.bbbb.cccc" format:JSON completion:^(W3wPlace *result, W3wError *error)
    {
    if (error)
        NSLog(@"There was an %@ error: %@", error.code, error.message);
    }];
```

## 6. Troubleshooting

If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:

**JSON**

```json
{
    "error": {
        "code": "QuotaExceeded",
        "message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
    }
}
```

For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).

## 7. Full example

Complete example using AutoSuggest to find a location.

**Objective-C**

```objective-c
#import "W3wGeocoder.h"
#import <CoreLocation/CoreLocation.h>

  W3wGeocoder *api = [[W3wGeocoder alloc] initWithApiKey:@"<Your Secret Key>"];

  AutoSuggestOption *france = [AutoSuggestOption clipToCountry:@"FR"];
  AutoSuggestOption *place  = [AutoSuggestOption focus:CLLocationCoordinate2DMake(48.856618, 2.3522411)];
  AutoSuggestOption *count  = [AutoSuggestOption numberResults:10];

  [api autosuggest:@"hangry.selfie.x" parameters:@[france, place, count] completion:^(NSArray *suggestions, W3wError *error)
    {
    if (error)
        NSLog(@"There was an %@ error: %@", error.code, error.message);
    else
      {
      NSLog(@"Suggestions Returned:");
      for (W3wSuggestion *suggestion in suggestions)
        {
        NSLog(@"%@ is near %@", suggestion.words, suggestion.nearestPlace);
        }
      }
      
    }];
```
