Skip to content

Migration guide to version 4.x

Clément Le Provost edited this page Sep 13, 2016 · 6 revisions

Overview

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 like NSNumber. 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).

Changes

Here is a detailed list of changes:

Common

Class Client:

  • Constant ErrorDomain removed. Error handling now uses dedicated error types: HTTPError and InvalidJSON
  • Properties timeout and searchTimeout are now writable
  • Method setHeader(_:value:) renamed to setHeader(withName:to:)
  • Method getHeader(_:) renamed to header(withName:)
  • Method getIndex(_:) renamed to index(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 to deleteIndex(withName:completionHandler:)
  • Method moveIndex(_:to:completionHandler:) renamed to moveIndex(from:to:completionHandler:)
  • Method copyIndex(_:to:completionHandler:) renamed to copyIndex(from:to:completionHandler:)
  • Method batch(_:completionHandler:) renamed to batch(operations;completionHandler:)
  • Method isAlive(_:) renamed to isAlive(completionHandler:)

Class Index:

  • Property indexName renamed to name
  • Method deleteObject(_:completionHandler:) renamed to deleteObject(withID:completionHandler:)
  • Method deleteObjects(_:completionHandler:) renamed to deleteObjects(withIDs:completionHandler:)
  • Method getObject(_:completionHandler:) renamed to getObject(withID:completionHandler:)
  • Method getObject(_:attributesToRetrieve:completionHandler:) renamed to getObject(withID:attributesToRetrieve:completionHandler:)
  • Method getObjects(_:completionHandler:) renamed to getObjects(withIDs:completionHandler:)
  • Method getObjects(_:attributesToRetrieve:completionHandler:) renamed to getObjects(withIDs:attributesToRetrieve:completionHandler:)
  • Method partialUpdateObject(_:objectID:completionHandler:) renamed to partialUpdateObject(_:withID:completionHandler:)
  • Method getSettings(_:) renamed to getSettings(completionHandler:)
  • Method setSettings(_:forwardToSlaves:completionHandler:) renamed to setSettings(_:forwardToReplicas:completionHandler:)
  • Method clearIndex(_:) renamed to clearIndex(completionHandler:)

Swift-specific

Objective-C-specific

Clone this wiki locally