-
Notifications
You must be signed in to change notification settings - Fork 67
Migration guide from Objective C to Swift API Client
Thibault Deutsch edited this page Jul 3, 2015
·
10 revisions
This guide explains how to migrate your code from the Objective-C API Client to the Swift API Client.
If you have any issue, please contact our team at support@algolia.com.
The latest version can always be found on GitHub and CocoaPods.
Objective-C API Client
pod 'AlgoliaSearch-Client', '~> 3.5'
Swift API Client
use_frameworks!
pod 'AlgoliaSearch-Client-Swift', '~> 1.4'
Objective-C API Client
#import "ASAPIClient.h"
ASAPIClient *apiClient = [ASAPIClient apiClientWithApplicationID:@"YourApplicationID" apiKey:@"YourAPIKey"];
Swift API Client
#import "AlgoliaSearch-Swift.h"
Client *apiClient = [Client clientWithAppID:@"YourApplicationID" apiKey:@"YourAPIKey"];
Objective-C API Client
[index search:query success:^(ASRemoteIndex *index, ASQuery *query, NSDictionary *result) {
// no error
} failure:^(ASRemoteIndex *index, ASQuery *query, NSString *errorMessage) {
// error
}];
Swift API Client
[index search:query block:^(NSDictionary * content, NSError * error) {
// error `nil` or `NSError` object
// content contains the results if no error
}];
If your project is in Swift or partially in Swift, you should use the Swift API Client. We don't support Swift in our Objective-C API Client.
Yes. If you are using the Objective-C API Client and do not want to upgrade then you can stick to it. We will continue to update and support it.