Skip to content

v1.1 API Changes

Jens Alfke edited this page May 12, 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.)

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

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

  • The .documentType property can help optimize indexing performance. If set, only documents whose JSON type property is equal to that string will be passed to the map function; others are skipped. This avoids having to load and parse documents that your map function would ignore anyway. Note: This property is not persistent: you'll need to set it on every launch, when you set the view's map block.
Clone this wiki locally