-
Notifications
You must be signed in to change notification settings - Fork 68
Migration guide to version 4.x
The main purpose of version 4 is to support Swift 3 (#74). It was also the opportunity to improve the “look and feel” of the library. Apart from that, no new major features were introduced.
Note: Since the Swift API Client is distributed in source form, in order to user version 4, you need to adopt Swift 3 in your own project.
Objective-C bridging has been revised (and, we hope, improved):
- The
Queryclass as seen from Swift no longer uses suboptimal types likeNSNumber. As a consequence, the infamous underscore-suffixed properties are no longer necessary. You can enjoy clean auto-completion:

… compared to the previous situation:

Note: Seen from Objective-C, the Query class still contains all properties with Objective-C compatible types (as before).
- Method names in Objective-C have been remapped to feel more natural (see below).
Note: Most changes are just a side effect of complying with the Swift API Design Guidelines, especially regarding argument labeling and using lower camel case for anything else but type (class and protocol) names.
Here is a detailed list of changes:
Class Client:
- Constant
ErrorDomainremoved. Error handling now uses dedicated error types:HTTPErrorandInvalidJSONError - Properties
timeoutandsearchTimeoutare now writable - Method
setHeader(_:value:)renamed tosetHeader(withName:to:) - Method
getHeader(_:)renamed toheader(withName:) - Method
getIndex(_:)renamed toindex(withName:)- Also,
Indexinstances are now shared among a givenClient
- Also,
- Method
deleteIndex(_:completionHandler:)renamed todeleteIndex(withName:completionHandler:) - Method
moveIndex(_:to:completionHandler:)renamed tomoveIndex(from:to:completionHandler:) - Method
copyIndex(_:to:completionHandler:)renamed tocopyIndex(from:to:completionHandler:) - Method
batch(_:completionHandler:)renamed tobatch(operations;completionHandler:) - Method
isAlive(_:)renamed toisAlive(completionHandler:)
Class Index:
- Property
indexNamerenamed toname - Method
deleteObject(_:completionHandler:)renamed todeleteObject(withID:completionHandler:) - Method
deleteObjects(_:completionHandler:)renamed todeleteObjects(withIDs:completionHandler:) - Method
getObject(_:completionHandler:)renamed togetObject(withID:completionHandler:) - Method
getObject(_:attributesToRetrieve:completionHandler:)renamed togetObject(withID:attributesToRetrieve:completionHandler:) - Method
getObjects(_:completionHandler:)renamed togetObjects(withIDs:completionHandler:) - Method
getObjects(_:attributesToRetrieve:completionHandler:)renamed togetObjects(withIDs:attributesToRetrieve:completionHandler:) - Method
partialUpdateObject(_:objectID:completionHandler:)renamed topartialUpdateObject(_:withID:completionHandler:) - Method
getSettings(_:)renamed togetSettings(completionHandler:) - Method
setSettings(_:forwardToSlaves:completionHandler:)renamed tosetSettings(_:forwardToReplicas:completionHandler:) - Method
clearIndex(_:)renamed toclearIndex(completionHandler:) - Method
batch(_:completionHandler:)renamed tobatch(operations:completionHandler:) - Method
browse(_:completionHandler:)renamed tobrowse(query:completionHandler:) - Method
browseFrom(_:completionHandler:)renamed tobrowse(from:completionHandler:) - Method
waitTask(_:completionHandler:)renamed towaitTask(withID:completionHandler:) - Methods
enableSearchCache(_:)anddisableSearchCache()replaced by two properties:searchCacheEnabledsearchCacheExpiringTimeInterval
Class MirroredIndex:
- Constants now lower camel case
- … except notification names (which in theory contradicts the Swift API Design Guidelines, but the system APIs follow the same convention)
- Notification names now typed
Notification.Name(NSNotificationNamein Objective-C) - Method
browseMirror(_:completionHandler:)renamed tobrowseMirror(query:completionHandler:) - Method
browseMirrorFrom(_:completionHandler:)renamed tobrowseMirror(from:completionHandler:) - Enum
Strategynow uses lower camel case for members
Class OfflineClient:
- Method
enableOfflineMode(_:)renamed toenableOfflineMode(licenseKey:)
Class Query:
- Enums
AlternativesAsExact,AroundRadius,ExactOnSingleWordQuery,QueryType,RemoveStopWords,RemoveWordsIfNoResultsandTypoTolerancenow use lower camel case for their members - Method
get(_:)renamed toparameter(withName:) - Method
set(_:value:)renamed tosetParameter(withName:to:) - Property
queryTypenow enum-typed, propertyqueryType_removed - Property
typoTolerancenow enum-typed, propertytypoTolerance_removed - Property
minWordSizefor1Typonow typedUInt? - Property
minWordSizefor2Typosnow typedUInt? - Property
allowTyposOnNumericTokensnow typedBool? - Property
ignorePluralsnow typedBool? - Property
advancedSyntaxnow typedBool? - Property
analyticsnow typedBool? - Property
synonymsnow typedBool? - Property
replaceSynonymsInHighlightnow typedBool? - Property
minProximitynow typedUInt? - Property
removeWordsIfNoResultsnow enum-typed, propertyremoveWordsIfNoResults_removed - Property
removeStopWordsnow enum-typed - Property
exactOnSingleWordQuerynow enum-typed, propertyexactOnSingleWordQuery_removed - Property
alternativesAsExactnow enum-typed, propertyalternativesAsExact_removed - Property
pagenow typedUInt? - Property
hitsPerPagenow typedUInt? - Property
getRankingInfonow typedBool? - Property
distinctnow typedUInt? - Property
maxValuesPerFacetnow typedUInt? - Property
aroundLatLngViaIPnow typedBool? - Property
aroundRadiusnow enum-typed - Property
aroundPrecisionnow typedUInt? - Property
minimumAroundRadiusnow typedUInt?
-
browse(from:completionHandler:)is mapped tobrowseFromCursor:completionHandler: -
batch(operations:completionHandler:)is mapped tobatchOperations:completionHandler: