-
Notifications
You must be signed in to change notification settings - Fork 67
Migration guide to version 4.x
The main purpose of version 4 is support for Swift 3 (#74). It was also the opportunity to improve a few areas where a breaking change was required.
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
Query
class 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
ErrorDomain
removed. Error handling now uses dedicated error types:HTTPError
andInvalidJSON
- Properties
timeout
andsearchTimeout
are now writable - Method
setHeader(_:value:)
renamed tosetHeader(withName:to:)
- Method
getHeader(_:)
renamed toheader(withName:)
- Method
getIndex(_:)
renamed toindex(withName:)
. Also, it caches instances between calls, so that the same instance is returned if the method is called twice with the same index name (and before the index is released by the caller). - 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
indexName
renamed 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:searchCacheEnabled
searchCacheExpiringTimeInterval
Class MirroredIndex
:
- Constants now lower camel case, except notification names. (This in theory breaks the Swift API Design Guidelines, but the system APIs follow the same convention.)
- Notification names now typed
Notification.Name
(NSNotificationName
in Objective-C) - Method
browseMirror(_:completionHandler:)
renamed tobrowseMirror(query:completionHandler:)
- Method
browseMirrorFrom(_:completionHandler:)
renamed tobrowseMirror(from:completionHandler:)
- Enum
Strategy
now uses lower camel case for members
Class OfflineClient
:
- Method
enableOfflineMode(_:)
renamed toenableOfflineMode(licenseKey:)
Class Query
:
- Enums
AlternativesAsExact
,AroundRadius
,ExactOnSingleWordQuery
,QueryType
,RemoveStopWords
,RemoveWordsIfNoResults
andTypoTolerance
now use lower camel case for their members - Method
get(_:)
renamed toparameter(withName:)
- Method
set(_:value:)
renamed tosetParameter(withName:to:)
- Property
queryType
now enum-typed, propertyqueryType_
removed - Property
typoTolerance
now enum-typed, propertytypoTolerance_
removed - Property
minWordSizefor1Typo
now typedUInt?
- Property
minWordSizefor2Typos
now typedUInt?
- Property
allowTyposOnNumericTokens
now typedBool?
- Property
ignorePlurals
now typedBool?
- Property
advancedSyntax
now typedBool?
- Property
analytics
now typedBool?
- Property
synonyms
now typedBool?
- Property
replaceSynonymsInHighlight
now typedBool?
- Property
minProximity
now typedUInt?
- Property
removeWordsIfNoResults
now enum-typed, propertyremoveWordsIfNoResults_
removed - Property
removeStopWords
now enum-typed - Property
exactOnSingleWordQuery
now enum-typed, propertyexactOnSingleWordQuery_
removed - Property
alternativesAsExact
now enum-typed, propertyalternativesAsExact_
removed - Property
page
now typedUInt?
- Property
hitsPerPage
now typedUInt?
- Property
getRankingInfo
now typedBool?
- Property
distinct
now typedUInt?
- Property
maxValuesPerFacet
now typedUInt?
- Property
aroundLatLngViaIP
now typedBool?
- Property
aroundRadius
now enum-typed - Property
aroundPrecision
now typedUInt?
- Property
minimumAroundRadius
now typedUInt?
-
browse(from:completionHandler:)
is mapped tobrowseFromCursor:completionHandler:
-
batch(operations:completionHandler:)
is mapped tobatchOperations:completionHandler: