Skip to content

v1.1 API Changes

Jens Alfke edited this page May 14, 2015 · 4 revisions

Here are all of the API changes from release 1.0.4 to 1.1 of Couchbase Lite for iOS (and Mac OS X.) You can get more information about any new method/property by looking for it in its header file and reading the documentation comment above it.

All Classes

  • The headers now use the new nullable attribute. Any parameters that aren't prefixed with nullable may not take nil values, and (starting in Xcode 6.3) will produce a compile error if you call them with a constant nil value. In Swift, a non-nullable parameter will be typed as non-optional (e.g. of type String rather than String?) -- this will make your app code simpler and clearer.

CBLAttachment

  • You can now read an attachment as a stream by calling -openContentStream. (Just make sure to close the stream when you're done.)
  • The .contentURL property is informally deprecated, because the file it points to will be encrypted (hence useless to you) if you've enabled database encryption.

CBLListener

  • -setAnonymousSSLIdentityWithLabel:error: enables SSL by creating an anonymous self-signed SSL certificate (stored in the device's keychain). This is not as useful as a "real" cert from a registrar, since it contains no identifying information, but it does serve to encrypt the replicator traffic, and a client can use cert-pinning across multiple connections to ensure it's connecting to the same device/app as before.

  • The .SSLIdentityDigest property returns a SHA digest of the listener's SSL cert's public key. This can be used as a fingerprint identifying the listener, which is useful in peer-to-peer pairing.

CBLManager

  • -databaseExistsNamed: lets you query for the existence of a database without opening it.
  • -registerEncryptionKey:forDatabaseNamed: is your entry point to database encryption.
  • -replaceDatabaseNamed:... has changed its parameters due to the new database layout. Since a CBL database is now stored as a directory, with the SQLite database and attachments inside, you only need to provide that one directory's path when importing a database.

CBLModel

  • Support for querying inverse relations:
    • The new method -findInverseOfRelation:fromClass: queries an inverse relation: it finds the other models in the database that have a specific property that references the receiver. See the header comments for more details.
    • It's also possible to declare a property whose value will be computed as an inverse-relation query, by implementing +inverseRelationForArrayProperty:.
  • CBLModel now has no public initializer methods, and you should not implement any yourself in subclasses.
    • Instead of calling -initWithNewDocumentInDatabase:, call +modelForNewDocumentInDatabase:.
    • In a subclass, to set up transient state of an instance, override -awakeFromInitializer.

CBLModelFactory

  • Added -documentTypeForClass: and -documentTypesForClass:, to look up which JSON type property(ies) are associated with a particular CBLModel subclass.

CBLQuery

  • CBLAllDocsMode now has a new value, kCBLBySequence, which produces a "changes feed" with documents ordered by their sequence number, i.e. in the order in which they were last changed.
  • CBLLiveQuery has a new method -queryOptionsChanged. Call this if you change the query's options (startKey, endKey, descending, etc.) after the live query has started running, so it'll pick up the changes.
  • Removed fullTextQuery and fullTextSnippets properties, as they're not supported with ForestDB storage.

CBLQueryBuilder

New in this release, CBLQueryBuilder lets you create Core Data-like queries using NSPredicates without having to manually define map functions. See the documentation for details.

CBLReplication

  • The .pendingDocumentIDs property and -isDocumentPending: method allow you to check which documents have local changes that haven't yet been pushed to the server.

CBLView

Clone this wiki locally