-
Notifications
You must be signed in to change notification settings - Fork 68
Migration guide to version 4.x
Clément Le Provost edited this page Sep 13, 2016
·
6 revisions
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.
Since the Swift API Client is distributed in source form, you obviously need to adopt Swift 3 in your own project for it to work with your code.
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:
TODO: Insert image
... compared to the previous situation:
TODO: Insert image
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).
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:)