├── .gitignore ├── README.md └── swift-couchbaselite ├── CouchbaseLite.framework ├── CouchbaseLite ├── Headers │ ├── CBLAttachment.h │ ├── CBLAuthenticator.h │ ├── CBLDatabase.h │ ├── CBLDatabaseChange.h │ ├── CBLDocument.h │ ├── CBLGeometry.h │ ├── CBLJSON.h │ ├── CBLManager.h │ ├── CBLModel.h │ ├── CBLModelFactory.h │ ├── CBLQuery+FullTextSearch.h │ ├── CBLQuery+Geo.h │ ├── CBLQuery.h │ ├── CBLReplication.h │ ├── CBLRevision.h │ ├── CBLUITableSource.h │ ├── CBLView.h │ ├── CouchbaseLite.h │ └── MYDynamicObject.h └── Info.plist ├── CouchbaseLiteListener.framework ├── CouchbaseLiteListener └── Headers │ └── CBLListener.h ├── bridging-header.h ├── swift-couchbaselite.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── swift-couchbaselite.xccheckout │ └── xcuserdata │ │ ├── zeissmirco.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── zemirco.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── zeissmirco.xcuserdatad │ └── xcschemes │ │ ├── swift-couchbaselite.xcscheme │ │ └── xcschememanagement.plist │ └── zemirco.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── swift-couchbaselite.xcscheme │ └── xcschememanagement.plist ├── swift-couchbaselite ├── AppDelegate.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist └── MainViewController.swift └── swift-couchbaseliteTests ├── Info.plist └── swift_couchbaseliteTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Swift CouchbaseLite Cheat Sheet 3 | 4 | Here is how to use CouchbaseLite in your Swift app. 5 | To get started read the 6 | [docs](http://developer.couchbase.com/mobile/develop/training/build-first-ios-app/create-new-project/index.html). 7 | 8 | #### Bridging header 9 | 10 | Add all necessary files to your 11 | [bridging header](https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/buildingcocoaapps/MixandMatch.html). 12 | 13 | ``` 14 | #import "CouchbaseLite.framework/Headers/CouchbaseLite.h" 15 | ``` 16 | 17 | #### Creating a manager 18 | 19 | ```swift 20 | var manager = CBLManager.sharedInstance() 21 | ``` 22 | 23 | #### Opening a database 24 | 25 | ```swift 26 | do { 27 | let db = try manager.databaseNamed("mydb") 28 | } catch { 29 | print(error) 30 | } 31 | ``` 32 | 33 | #### Creating documents 34 | 35 | ```swift 36 | do { 37 | let properties = [ 38 | "name": "mirco", 39 | "email": "mirco.zeiss@gmail.com", 40 | "repo": "swift-couchbaselite-cheatsheet" 41 | ] 42 | 43 | let doc = db.createDocument() 44 | try doc.putProperties(properties) 45 | } catch { 46 | print(error) 47 | } 48 | ``` 49 | 50 | #### Creating and initializing views 51 | 52 | ```swift 53 | let view = db.viewNamed("name") 54 | let block: CBLMapBlock = { (doc, emit) in 55 | emit(doc["name"], nil) 56 | } 57 | 58 | view.setMapBlock(block, version: "1") 59 | ``` 60 | 61 | #### Querying views 62 | 63 | ```swift 64 | do { 65 | let query = db.viewNamed("name").createQuery() 66 | query.keys = ["mirco"] 67 | let result = try query.run() 68 | 69 | let count = Int(result.count) 70 | 71 | for var index = 0; index < count; ++index { 72 | print(result.rowAtIndex(UInt(index)).document) 73 | } 74 | } catch { 75 | print(error) 76 | } 77 | ``` 78 | 79 | For some reason a `for-in` loop doesn't work. 80 | 81 | ```swift 82 | for row in result { 83 | println(row.value) 84 | } 85 | ``` 86 | 87 | Xcode starts to freak out and throws errors. 88 | 89 | #### Query by timestamp 90 | 91 | Add document with timestamp. 92 | 93 | ```swift 94 | let timestamp = NSDate().timeIntervalSince1970 * 1000 as Double 95 | 96 | let person: Dictionary[String, String]> = [ 97 | "timestamp": timestamp, 98 | "type": "person", 99 | "name": "mirco" 100 | ] 101 | ``` 102 | 103 | Now query the view and get all persons in the order they were added to db. 104 | 105 | ```swift 106 | let db = getDatabase("people") 107 | let view = db.viewNamed("persons") 108 | let map: CBLMapBlock = { (doc, emit) in 109 | if doc["type"] { 110 | if doc["type"] as NSString == "person" { 111 | emit(doc["timestamp"] as Double, nil) 112 | } 113 | } 114 | } 115 | view.setMapBlock(map, version: "1") 116 | 117 | // get all moves between date in the future 118 | // 2999-12-31 = 32503593600000 119 | // and date in the past 120 | // 2013-01-01 = 1356998400000 121 | 122 | do { 123 | let query = db.viewNamed("persons").createQuery() 124 | query.startKey = 1356998400000 as Double 125 | query.endKey = 32503593600000 as Double 126 | let data = try query.run() 127 | } catch { 128 | print(error) 129 | } 130 | ``` 131 | 132 | #### Updating a document 133 | 134 | ```swift 135 | var db = getDatabase("people") 136 | var personDocument = db.documentWithID(personId) 137 | 138 | do { 139 | try personDocument.update({ (newRev: CBLUnsavedRevision!) in 140 | newRev["name"] = "john" 141 | return true 142 | }) 143 | } catch { 144 | print(error) 145 | } 146 | 147 | ``` 148 | 149 | #### Replication 150 | 151 | ```swift 152 | var url = NSURL(string: "http://127.0.0.1:5984/test") 153 | var push = db.createPushReplication(url) 154 | var pull = db.createPullReplication(url) 155 | push.continuous = true 156 | pull.continuous = true 157 | 158 | push.start() 159 | pull.start() 160 | ``` 161 | 162 | ## License 163 | 164 | MIT 165 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/CouchbaseLite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-couchbaselite-cheatsheet/b137653164c7dad6ecae01506c4b955003cb25d7/swift-couchbaselite/CouchbaseLite.framework/CouchbaseLite -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLAttachment.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLAttachment.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/21/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDocument, CBLRevision, CBLSavedRevision; 11 | 12 | 13 | /** A binary attachment to a document revision. 14 | Existing attachments can be gotten from -[CBLRevision attachmentNamed:]. 15 | New attachments can be created by calling the -setAttachment:... methods of CBLNewRevision or 16 | CBLModel. */ 17 | @interface CBLAttachment : NSObject 18 | 19 | /** The owning document revision. */ 20 | @property (readonly, retain) CBLRevision* revision; 21 | 22 | /** The owning document. */ 23 | @property (readonly) CBLDocument* document; 24 | 25 | /** The filename. */ 26 | @property (readonly, copy) NSString* name; 27 | 28 | /** The MIME type of the contents. */ 29 | @property (readonly) NSString* contentType; 30 | 31 | /** The length in bytes of the contents. */ 32 | @property (readonly) UInt64 length; 33 | 34 | /** The CouchbaseLite metadata about the attachment, that lives in the document. */ 35 | @property (readonly) NSDictionary* metadata; 36 | 37 | /** The data of the attachment. */ 38 | @property (readonly) NSData* content; 39 | 40 | /** The URL of the file containing the contents. (This is always a 'file:' URL.) 41 | This file must be treated as read-only! DO NOT MODIFY OR DELETE IT. */ 42 | @property (readonly) NSURL* contentURL; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLAuthenticator.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLAuthenticator.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 4/11/14. 6 | // Copyright (c) 2014 Couchbase, Inc. All rights reserved. 7 | 8 | 9 | #import 10 | 11 | 12 | /** The CBLAuthenticator protocol defines objects that can authenticate a user to a remote database 13 | server. An object conforming to this protocol is acquired from the CBLAuthenticator _class_'s 14 | factory methods, and is used by setting it as a CBLReplication's .authenticator property. 15 | This protocol is currently entirely opaque and not intended for applications to implement. 16 | The authenticator types are limited to those createable by factory methods. */ 17 | @protocol CBLAuthenticator 18 | // No user-servicable parts inside. 19 | @end 20 | 21 | 22 | /** The CBLAuthenticator class provides factory methods for creating authenticator objects, for use 23 | with the .authenticator property of a CBLReplication. */ 24 | @interface CBLAuthenticator : NSObject 25 | 26 | /** Creates an authenticator that will log in using HTTP Basic auth with the given user name and 27 | password. This should only be used over an SSL/TLS connection, as otherwise it's very easy for 28 | anyone sniffing network traffic to read the password. */ 29 | + (id) basicAuthenticatorWithName: (NSString*)name 30 | password: (NSString*)password; 31 | 32 | /** Creates an authenticator that will authenticate to a Couchbase Sync Gateway server using 33 | Facebook credentials. The token string must be an active Facebook login token. On iOS you can 34 | acquire one from the Accounts framework, or you can use Facebook's SDK to implement the 35 | login process. */ 36 | + (id) facebookAuthenticatorWithToken: (NSString*)token; 37 | 38 | /** Creates an authenticator that will authenticate to a Couchbase Sync Gateway server using the 39 | user's email address, with the Persona protocol (http://persona.org). The "assertion" token 40 | must have been acquired using the client-side Persona auth procedure; you can use the library 41 | https://github.com/couchbaselabs/browserid-ios to do this. */ 42 | + (id) personaAuthenticatorWithAssertion: (NSString*)assertion; 43 | 44 | /** Creates an authenticator that will authenticate to a CouchDB server using OAuth version 1. 45 | The parameters must have been acquired using the client-side OAuth login procedure. There are 46 | several iOS and Mac implementations of this, such as 47 | https://github.com/couchbaselabs/ios-oauthconsumer */ 48 | + (id) OAuth1AuthenticatorWithConsumerKey: (NSString*)consumerKey 49 | consumerSecret: (NSString*)consumerSecret 50 | token: (NSString*)token 51 | tokenSecret: (NSString*)tokenSecret 52 | signatureMethod: (NSString*)signatureMethod; 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLDatabase.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLDatabase.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/17/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CBLView.h" 11 | @class CBLManager, CBLDocument, CBLRevision, CBLSavedRevision, CBLView, CBLQuery, CBLReplication; 12 | @protocol CBLValidationContext; 13 | 14 | 15 | /** Validation block, used to approve revisions being added to the database. 16 | The block should call `[context reject]` or `[context rejectWithMessage:]` if the proposed 17 | new revision is invalid. */ 18 | typedef void (^CBLValidationBlock) (CBLRevision* newRevision, 19 | id context); 20 | 21 | #define VALIDATIONBLOCK(BLOCK) ^void(CBLRevision* newRevision, id context)\ 22 | {BLOCK} 23 | 24 | /** Filter block, used in changes feeds and replication. */ 25 | typedef BOOL (^CBLFilterBlock) (CBLSavedRevision* revision, NSDictionary* params); 26 | 27 | #define FILTERBLOCK(BLOCK) ^BOOL(CBLSavedRevision* revision, NSDictionary* params) {BLOCK} 28 | 29 | 30 | /** An external object that knows how to convert source code into an executable filter. */ 31 | @protocol CBLFilterCompiler 32 | - (CBLFilterBlock) compileFilterFunction: (NSString*)filterSource language: (NSString*)language; 33 | @end 34 | 35 | 36 | /** A CouchbaseLite database. */ 37 | @interface CBLDatabase : NSObject 38 | 39 | /** The database's name. */ 40 | @property (readonly) NSString* name; 41 | 42 | /** The database manager that owns this database. */ 43 | @property (readonly) CBLManager* manager; 44 | 45 | /** The number of documents in the database. */ 46 | @property (readonly) NSUInteger documentCount; 47 | 48 | /** The latest sequence number used. 49 | Every new revision is assigned a new sequence number, so this property increases monotonically 50 | as changes are made to the database. It can be used to check whether the database has changed 51 | between two points in time. */ 52 | @property (readonly) SInt64 lastSequenceNumber; 53 | 54 | /** The URL of the database in the REST API. You can access this URL within this process, 55 | using NSURLConnection or other APIs that use that (such as XMLHTTPRequest inside a WebView), 56 | but it isn't available outside the process. 57 | This method is only available if you've linked with the CouchbaseLiteListener framework. */ 58 | @property (readonly) NSURL* internalURL; 59 | 60 | 61 | #pragma mark - HOUSEKEEPING: 62 | 63 | /** Compacts the database file by purging non-current JSON bodies, pruning revisions older than 64 | the maxRevTreeDepth, deleting unused attachment files, and vacuuming the SQLite database. */ 65 | - (BOOL) compact: (NSError**)outError; 66 | 67 | /** The maximum depth of a document's revision tree (or, max length of its revision history.) 68 | Revisions older than this limit will be deleted during a -compact: operation. 69 | Smaller values save space, at the expense of making document conflicts somewhat more likely. */ 70 | @property NSUInteger maxRevTreeDepth; 71 | 72 | /** Deletes the database. */ 73 | - (BOOL) deleteDatabase: (NSError**)outError; 74 | 75 | /** Changes the database's unique IDs to new random values. 76 | Ordinarily you should never need to call this method; it's only made public to fix databases 77 | that are already affected by bug github.com/couchbase/couchbase-lite-ios/issues/145 . 78 | Make sure you only call this once, to fix that problem, because every call has the side effect 79 | of resetting all replications, making them run slow the next time. */ 80 | - (BOOL) replaceUUIDs: (NSError**)outError; 81 | 82 | 83 | #pragma mark - DOCUMENT ACCESS: 84 | 85 | /** Instantiates a CBLDocument object with the given ID. 86 | Doesn't touch the on-disk database; a document with that ID doesn't even need to exist yet. 87 | CBLDocuments are cached, so there will never be more than one instance (in this database) 88 | at a time with the same documentID. */ 89 | - (CBLDocument*) documentWithID: (NSString*)docID __attribute__((nonnull)); 90 | 91 | /** Instantiates a CBLDocument object with the given ID. 92 | Unlike -documentWithID: this method loads the document from the database, and returns nil if 93 | no such document exists. 94 | CBLDocuments are cached, so there will never be more than one instance (in this database) 95 | at a time with the same documentID. */ 96 | - (CBLDocument*) existingDocumentWithID: (NSString*)docID __attribute__((nonnull)); 97 | 98 | /** Same as -documentWithID:. Enables "[]" access in Xcode 4.4+ */ 99 | - (CBLDocument*)objectForKeyedSubscript: (NSString*)key __attribute__((nonnull)); 100 | 101 | /** Creates a new CBLDocument object with no properties and a new (random) UUID. 102 | The document will be saved to the database when you call -putProperties: on it. */ 103 | - (CBLDocument*) createDocument; 104 | 105 | 106 | #pragma mark - LOCAL DOCUMENTS: 107 | 108 | 109 | /** Returns the contents of the local document with the given ID, or nil if none exists. */ 110 | - (NSDictionary*) existingLocalDocumentWithID: (NSString*)localDocID __attribute__((nonnull)); 111 | 112 | /** Sets the contents of the local document with the given ID. Unlike CouchDB, no revision-ID 113 | checking is done; the put always succeeds. If the properties dictionary is nil, the document 114 | will be deleted. */ 115 | - (BOOL) putLocalDocument: (NSDictionary*)properties 116 | withID: (NSString*)localDocID 117 | error: (NSError**)outError __attribute__((nonnull(2))); 118 | 119 | /** Deletes the local document with the given ID. */ 120 | - (BOOL) deleteLocalDocumentWithID: (NSString*)localDocID 121 | error: (NSError**)outError __attribute__((nonnull(1))); 122 | 123 | 124 | #pragma mark - VIEWS AND OTHER CALLBACKS: 125 | 126 | /** Returns a query that matches all documents in the database. 127 | This is like querying an imaginary view that emits every document's ID as a key. */ 128 | - (CBLQuery*) createAllDocumentsQuery; 129 | 130 | /** Creates a one-shot query with the given map function. This is equivalent to creating an 131 | anonymous CBLView and then deleting it immediately after querying it. It may be useful during 132 | development, but in general this is inefficient if this map will be used more than once, 133 | because the entire view has to be regenerated from scratch every time. */ 134 | - (CBLQuery*) slowQueryWithMap: (CBLMapBlock)mapBlock __attribute__((nonnull)); 135 | 136 | /** Returns a CBLView object for the view with the given name. 137 | (This succeeds even if the view doesn't already exist, but the view won't be added to the database until the CBLView is assigned a map function.) */ 138 | - (CBLView*) viewNamed: (NSString*)name __attribute__((nonnull)); 139 | 140 | /** Returns the existing CBLView with the given name, or nil if none. */ 141 | - (CBLView*) existingViewNamed: (NSString*)name __attribute__((nonnull)); 142 | 143 | /** Defines or clears a named document validation function. 144 | Before any change to the database, all registered validation functions are called and given a 145 | chance to reject it. (This includes incoming changes from a pull replication.) */ 146 | - (void) setValidationNamed: (NSString*)validationName asBlock: (CBLValidationBlock)validationBlock 147 | __attribute__((nonnull(1))); 148 | 149 | /** Returns the existing document validation function (block) registered with the given name. 150 | Note that validations are not persistent -- you have to re-register them on every launch. */ 151 | - (CBLValidationBlock) validationNamed: (NSString*)validationName __attribute__((nonnull)); 152 | 153 | /** Defines or clears a named filter function. 154 | Filters are used by push replications to choose which documents to send. */ 155 | - (void) setFilterNamed: (NSString*)filterName asBlock: (CBLFilterBlock)filterBlock 156 | __attribute__((nonnull(1))); 157 | 158 | /** Returns the existing filter function (block) registered with the given name. 159 | Note that filters are not persistent -- you have to re-register them on every launch. */ 160 | - (CBLFilterBlock) filterNamed: (NSString*)filterName __attribute__((nonnull)); 161 | 162 | /** Registers an object that can compile source code into executable filter blocks. */ 163 | + (void) setFilterCompiler: (id)compiler; 164 | 165 | /** Returns the currently registered filter compiler (nil by default). */ 166 | + (id) filterCompiler; 167 | 168 | 169 | #pragma mark - TRANSACTIONS / THREADING: 170 | 171 | /** Runs the block within a transaction. If the block returns NO, the transaction is rolled back. 172 | Use this when performing bulk write operations like multiple inserts/updates; it saves the 173 | overhead of multiple SQLite commits, greatly improving performance. */ 174 | - (BOOL) inTransaction: (BOOL(^)(void))block __attribute__((nonnull(1))); 175 | 176 | /** Runs the block asynchronously on the database's dispatch queue or thread. 177 | Unlike the rest of the API, this can be called from any thread, and provides a limited form 178 | of multithreaded access to Couchbase Lite. */ 179 | - (void) doAsync: (void (^)())block __attribute__((nonnull(1))); 180 | 181 | /** Runs the block _synchronously_ on the database's dispatch queue or thread: this method does 182 | not return until after the block has completed. 183 | Unlike the rest of the API, this can _only_ be called from other threads/queues: If you call it 184 | from the same thread or dispatch queue that the database runs on, **it will deadlock!** */ 185 | - (void) doSync: (void (^)())block __attribute__((nonnull(1))); 186 | 187 | 188 | #pragma mark - REPLICATION: 189 | 190 | /** Returns an array of all current, running CBLReplications involving this database. */ 191 | - (NSArray*) allReplications; 192 | 193 | /** Creates a replication that will 'push' this database to a remote database at the given URL. 194 | This always creates a new replication, even if there is already one to the given URL. 195 | You must call -start on the replication to start it. */ 196 | - (CBLReplication*) createPushReplication: (NSURL*)url; 197 | 198 | /** Creates a replication that will 'pull' from a remote database at the given URL to this database. 199 | This always creates a new replication, even if there is already one from the given URL. 200 | You must call -start on the replication to start it. */ 201 | - (CBLReplication*) createPullReplication: (NSURL*)url; 202 | 203 | 204 | @end 205 | 206 | 207 | 208 | 209 | /** This notification is posted by a CBLDatabase in response to document changes. 210 | The notification's userInfo dictionary's "changes" key contains an NSArray of 211 | CBLDatabaseChange objects that describe the revisions that were added. */ 212 | extern NSString* const kCBLDatabaseChangeNotification; 213 | 214 | 215 | 216 | 217 | /** The type of callback block passed to -[CBLValidationContext enumerateChanges:]. */ 218 | typedef BOOL (^CBLChangeEnumeratorBlock) (NSString* key, id oldValue, id newValue); 219 | 220 | 221 | 222 | /** Context passed into a CBLValidationBlock. */ 223 | @protocol CBLValidationContext 224 | 225 | /** The contents of the current revision of the document, or nil if this is a new document. */ 226 | @property (readonly) CBLSavedRevision* currentRevision; 227 | 228 | /** Rejects the proposed new revision. */ 229 | - (void) reject; 230 | 231 | /** Rejects the proposed new revision. Any resulting error will contain the provided message; 232 | for example, if the change came from an external HTTP request, the message will be in the 233 | response status line. The default message is "invalid document". */ 234 | - (void) rejectWithMessage: (NSString*)message; 235 | 236 | 237 | #pragma mark - CONVENIENCE METHODS: 238 | 239 | /** Returns an array of all the keys whose values are different between the current and new revisions. */ 240 | @property (readonly) NSArray* changedKeys; 241 | 242 | /** Calls the 'enumerator' block for each key that's changed, passing both the old and new values. 243 | If the block returns NO, the enumeration stops and rejects the revision, and the method returns 244 | NO; else the method returns YES. */ 245 | - (BOOL) validateChanges: (CBLChangeEnumeratorBlock)enumerator; 246 | 247 | @end 248 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLDatabaseChange.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLDatabaseChange.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 1/18/13. 6 | // Copyright (c) 2013 Couchbase, Inc. All rights reserved. 7 | // 8 | // 9 | 10 | #import 11 | 12 | 13 | /** Identifies a change to a database, that is, a newly added document revision. 14 | The CBLDocumentChangeNotification contains one of these in the "change" key of its 15 | userInfo dictionary, and CBLDatabaseChangeNotification contains an NSArray in "changes". */ 16 | @interface CBLDatabaseChange : NSObject 17 | 18 | /** The ID of the document that changed. */ 19 | @property (readonly) NSString* documentID; 20 | 21 | /** The ID of the newly-added revision. */ 22 | @property (readonly) NSString* revisionID; 23 | 24 | /** Is the new revision the document's current (default, winning) one? 25 | If not, there's a conflict. */ 26 | @property (readonly) BOOL isCurrentRevision; 27 | 28 | /** YES if the document is in conflict. (The conflict might pre-date this change.) */ 29 | @property (readonly) BOOL inConflict; 30 | 31 | /** The remote database URL that this change was pulled from, if any. */ 32 | @property (readonly) NSURL* source; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLDocument.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/4/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import "CBLDatabase.h" 10 | @class CBLSavedRevision, CBLUnsavedRevision, CBLDatabaseChange; 11 | @protocol CBLDocumentModel; 12 | 13 | 14 | /** A CouchbaseLite document (as opposed to any specific revision of it.) */ 15 | @interface CBLDocument : NSObject 16 | 17 | /** The document's owning database. */ 18 | @property (readonly) CBLDatabase* database; 19 | 20 | /** The document's ID. */ 21 | @property (readonly) NSString* documentID; 22 | 23 | /** An abbreviated form of the the documentID that looks like "xxxx..xxxx". Useful in logging. */ 24 | @property (readonly) NSString* abbreviatedID; 25 | 26 | /** Is this document deleted? (That is, does its current revision have the '_deleted' property?) */ 27 | @property (readonly) BOOL isDeleted; 28 | 29 | /** Has this document either been deleted or removed from available Sync Gateway channels? 30 | (That is, does its current revision have a '_deleted' or '_removed' property?) */ 31 | @property (readonly) BOOL isGone; 32 | 33 | /** Deletes this document by adding a deletion revision. 34 | This will be replicated to other databases. */ 35 | - (BOOL) deleteDocument: (NSError**)outError; 36 | 37 | /** Purges this document from the database; this is more than deletion, it forgets entirely about it. 38 | The purge will NOT be replicated to other databases. */ 39 | - (BOOL) purgeDocument: (NSError**)outError; 40 | 41 | 42 | #pragma mark REVISIONS: 43 | 44 | /** The ID of the current revision (if known; else nil). */ 45 | @property (readonly, copy) NSString* currentRevisionID; 46 | 47 | /** The current/latest revision. This object is cached. */ 48 | @property (readonly) CBLSavedRevision* currentRevision; 49 | 50 | /** The revision with the specified ID. */ 51 | - (CBLSavedRevision*) revisionWithID: (NSString*)revisionID; 52 | 53 | /** Returns the document's history as an array of CBLRevisions. (See CBLRevision's method.) */ 54 | - (NSArray*) getRevisionHistory: (NSError**)outError; 55 | 56 | /** Returns all the current conflicting revisions of the document. If the document is not 57 | in conflict, only the single current revision will be returned. */ 58 | - (NSArray*) getConflictingRevisions: (NSError**)outError; 59 | 60 | /** Returns all the leaf revisions in the document's revision tree, 61 | including deleted revisions (i.e. previously-resolved conflicts.) */ 62 | - (NSArray*) getLeafRevisions: (NSError**)outError; 63 | 64 | /** Creates an unsaved new revision whose parent is the currentRevision, 65 | or which will be the first revision if the document doesn't exist yet. 66 | You can modify this revision's properties and attachments, then save it. 67 | No change is made to the database until/unless you save the new revision. */ 68 | - (CBLUnsavedRevision*) newRevision; 69 | 70 | 71 | #pragma mark PROPERTIES: 72 | 73 | /** The contents of the current revision of the document. 74 | This is shorthand for self.currentRevision.properties. 75 | Any keys in the dictionary that begin with "_", such as "_id" and "_rev", contain CouchbaseLite 76 | metadata. */ 77 | @property (readonly, copy) NSDictionary* properties; 78 | 79 | /** The user-defined properties, without the ones reserved by CouchDB. 80 | This is based on -properties, with every key whose name starts with "_" removed. */ 81 | @property (readonly, copy) NSDictionary* userProperties; 82 | 83 | /** Shorthand for [self.properties objectForKey: key]. */ 84 | - (id) propertyForKey: (NSString*)key __attribute__((nonnull)); 85 | 86 | /** Same as -propertyForKey:. Enables "[]" access in Xcode 4.4+ */ 87 | - (id)objectForKeyedSubscript:(NSString*)key __attribute__((nonnull)); 88 | 89 | /** Saves a new revision. The properties dictionary must have a "_rev" property whose ID matches the current revision's (as it will if it's a modified copy of this document's .properties 90 | property.) */ 91 | - (CBLSavedRevision*) putProperties: (NSDictionary*)properties 92 | error: (NSError**)outError __attribute__((nonnull(1))); 93 | 94 | /** Saves a new revision by letting the caller update the existing properties. 95 | This method handles conflicts by retrying (calling the block again). 96 | The block body should modify the properties of the new revision and return YES to save or 97 | NO to cancel. Be careful: the block can be called multiple times if there is a conflict! 98 | @param block Will be called on each attempt to save. Should update the given revision's 99 | properties and then return YES, or just return NO to cancel. 100 | @param outError Will point to the error, if the method returns nil. (If the callback block 101 | cancels by returning nil, the error will be nil.) If this parameter is NULL, no 102 | error will be stored. 103 | @return The new saved revision, or nil on error or cancellation. 104 | */ 105 | - (CBLSavedRevision*) update: (BOOL(^)(CBLUnsavedRevision*))block 106 | error: (NSError**)outError __attribute__((nonnull(1))); 107 | 108 | 109 | #pragma mark MODEL: 110 | 111 | /** Optional reference to an application-defined model object representing this document. 112 | Usually this is a CBLModel, but you can implement your own model classes if you want. 113 | Note that this is a weak reference. */ 114 | @property (weak) id modelObject; 115 | 116 | 117 | @end 118 | 119 | 120 | 121 | /** Protocol that CBLDocument model objects must implement. See the CBLModel class. */ 122 | @protocol CBLDocumentModel 123 | /** Called whenever a new revision is added to the document. 124 | (Equivalent to kCBLDocumentChangeNotification.) */ 125 | - (void) CBLDocument: (CBLDocument*)doc 126 | didChange: (CBLDatabaseChange*)change __attribute__((nonnull)); 127 | @end 128 | 129 | 130 | 131 | /** This notification is posted by a CBLDocument in response to a change, i.e. a new revision. 132 | The notification's userInfo contains a "change" property whose value is a CBLDatabaseChange 133 | containing details of the change. 134 | NOTE: This is *not* a way to detect changes to all documents. Only already-existing CBLDocument 135 | objects will post this notification, so when a document changes in the database but there is 136 | not currently any CBLDocument instance representing it, no notification will be posted. 137 | If you want to observe all document changes in a database, use kCBLDatabaseChangeNotification.*/ 138 | extern NSString* const kCBLDocumentChangeNotification; 139 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLGeometry.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLGeometry.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 9/22/13. 6 | // Copyright (c) 2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** A 2D geometric point. */ 13 | typedef struct CBLGeoPoint { 14 | double x, y; 15 | } CBLGeoPoint; 16 | 17 | /** A 2D geometric rectangle. 18 | Note that unlike CGRect and NSRect, this stores max coords, not size. 19 | A rectangle with max coords equal to the min is equivalent to a point. 20 | It is illegal for the max coords to be less than the min. */ 21 | typedef struct CBLGeoRect { 22 | CBLGeoPoint min, max; 23 | } CBLGeoRect; 24 | 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | 31 | /** Compares two rectangles for equality. */ 32 | static inline BOOL CBLGeoRectEqual(CBLGeoRect a, CBLGeoRect b) { 33 | return a.min.x == b.min.x && a.min.y == b.min.y && a.max.x == b.max.x && a.max.y == b.max.y; 34 | } 35 | 36 | /** Returns YES if a rectangle is empty, i.e. equivalent to a single point. */ 37 | static inline BOOL CBLGeoRectIsEmpty(CBLGeoRect r) { 38 | return r.min.x == r.max.x && r.min.y == r.max.y; 39 | } 40 | 41 | 42 | /** Converts a string of four comma-separated numbers ("x0,y0,x1,y1") to a rectangle. */ 43 | BOOL CBLGeoCoordsStringToRect(NSString* coordsStr, CBLGeoRect* outRect); 44 | 45 | 46 | #pragma mark - CONVERTING TO/FROM JSON: 47 | 48 | /** Converts a point to GeoJSON format. 49 | For details see http://geojson.org/geojson-spec.html#point */ 50 | NSDictionary* CBLGeoPointToJSON(CBLGeoPoint pt); 51 | 52 | /** Converts a rectangle to GeoJSON format (as a polygon.) 53 | For details see http://geojson.org/geojson-spec.html#polygon */ 54 | NSDictionary* CBLGeoRectToJSON(CBLGeoRect rect); 55 | 56 | /** Computes the bounding box of a GeoJSON object. 57 | Currently only implemented for points and polygons. */ 58 | BOOL CBLGeoJSONBoundingBox(NSDictionary* geoJSON, CBLGeoRect* outBBox); 59 | 60 | 61 | /** Converts a point to a JSON-compatible array of two coordinates. */ 62 | NSArray* CBLGeoPointToCoordPair(CBLGeoPoint pt); 63 | 64 | /** Converts a JSON array of two coordinates [x,y] back into a point. */ 65 | BOOL CBLGeoCoordPairToPoint(NSArray* coords, CBLGeoPoint* outPoint); 66 | 67 | /** Converts a JSON array of four coordinates [x0, y0, x1, y1] to a rectangle. */ 68 | BOOL CBLGeoCoordsToRect(NSArray* coords, CBLGeoRect* outRect); 69 | 70 | #pragma mark - KEYS FOR MAP FUNCTIONS: 71 | 72 | /** Returns a special value that, when emitted as a key, is indexed as a geometric point. 73 | Used inside a map block, like so: `emit(CBLPointKey(3.0, 4.0), value);` */ 74 | id CBLGeoPointKey(double x, double y); 75 | 76 | /** Returns a special value that, when emitted as a key, is indexed as a geometric rectangle. */ 77 | id CBLGeoRectKey(double x0, double y0, double x1, double y1); 78 | 79 | /** Returns a special value that, when emitted as a key, is indexed as a GeoJSON 80 | shape. Currently only its bounding box is stored. 81 | Only points and polygons are supported; other shapes return nil. */ 82 | id CBLGeoJSONKey(NSDictionary* geoJSON); 83 | 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLJSON.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLJSON.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 2/27/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** Identical to the corresponding NSJSON option flags. */ 13 | enum { 14 | CBLJSONReadingMutableContainers = (1UL << 0), 15 | CBLJSONReadingMutableLeaves = (1UL << 1), 16 | CBLJSONReadingAllowFragments = (1UL << 2) 17 | }; 18 | typedef NSUInteger CBLJSONReadingOptions; 19 | 20 | /** Identical to the corresponding NSJSON option flags, with one addition. */ 21 | enum { 22 | CBLJSONWritingPrettyPrinted = (1UL << 0), 23 | 24 | CBLJSONWritingAllowFragments = (1UL << 23) /**< Allows input to be an NSString or NSValue. */ 25 | }; 26 | typedef NSUInteger CBLJSONWritingOptions; 27 | 28 | 29 | /** Useful extensions for JSON serialization/parsing. */ 30 | @interface CBLJSON : NSJSONSerialization 31 | 32 | /** Same as -dataWithJSONObject... but returns an NSString. */ 33 | + (NSString*) stringWithJSONObject:(id)obj 34 | options:(CBLJSONWritingOptions)opt 35 | error:(NSError **)error; 36 | 37 | /** Given valid JSON data representing a dictionary, inserts the contents of the given NSDictionary into it and returns the resulting JSON data. 38 | This does not parse or regenerate the JSON, so it's quite fast. 39 | But it will generate invalid JSON if the input JSON begins or ends with whitespace, or if the dictionary contains any keys that are already in the original JSON. */ 40 | + (NSData*) appendDictionary: (NSDictionary*)dict 41 | toJSONDictionaryData: (NSData*)json; 42 | 43 | /** Encodes an NSDate as a string in ISO-8601 format. */ 44 | + (NSString*) JSONObjectWithDate: (NSDate*)date; 45 | 46 | /** Parses an ISO-8601 formatted date string to an NSDate object. 47 | If the object is not a string, or not valid ISO-8601, it returns nil. */ 48 | + (NSDate*) dateWithJSONObject: (id)jsonObject; 49 | 50 | /** Parses an ISO-8601 formatted date string to an absolute time (timeSinceReferenceDate). 51 | If the object is not a string, or not valid ISO-8601, it returns a NAN value. */ 52 | + (CFAbsoluteTime) absoluteTimeWithJSONObject: (id)jsonObject; 53 | 54 | /** Follows a JSON-Pointer, returning the value pointed to, or nil if nothing. 55 | See spec at: http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-04 */ 56 | + (id) valueAtPointer: (NSString*)pointer inObject: (id)object; 57 | 58 | /** Encodes an NSData as a string in Base64 format. */ 59 | + (NSString*) base64StringWithData: (NSData*)data; 60 | 61 | /** Parses a Base64-encoded string into an NSData object. 62 | If the object is not a string, or not valid Base64, it returns nil. */ 63 | + (NSData*) dataWithBase64String: (id)jsonObject; 64 | 65 | /** Estimates the amount of memory used by the object and those it references. */ 66 | + (size_t) estimateMemorySize: (id)object; 67 | 68 | @end 69 | 70 | 71 | /** Wrapper for an NSArray of JSON data, that avoids having to parse the data if it's not used. 72 | NSData objects in the array will be parsed into native objects before being returned to the caller from -objectAtIndex. */ 73 | @interface CBLLazyArrayOfJSON : NSArray 74 | 75 | /** Initialize a lazy array. 76 | @param array An NSArray of NSData objects, each containing JSON. */ 77 | - (instancetype) initWithMutableArray: (NSMutableArray*)array; 78 | @end 79 | 80 | 81 | typedef void (^CBLOnMutateBlock)(); 82 | 83 | /** Protocol for classes whose instances can encode themselves as JSON. 84 | Such classes can be used directly as property types in CBLModel subclasses. */ 85 | @protocol CBLJSONEncoding 86 | - (id) initWithJSON: (id)jsonObject; 87 | - (id) encodeAsJSON; 88 | 89 | @optional 90 | /** If an implementation has mutable persistent state, it should implement this method. 91 | The implementation should save a copy of the block in an instance variable, and call the block 92 | whenever the instance's state has changed such that -encodeAsJSON will now return a different 93 | result. 94 | This allows the object's owner (typically a CBLModel) to detect such changes and mark itself 95 | as needing to be saved. */ 96 | - (void) setOnMutate: (CBLOnMutateBlock)onMutate; 97 | @end 98 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLManager.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/19/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDatabase; 11 | 12 | 13 | /** Option flags for CBLManager initialization. */ 14 | typedef struct CBLManagerOptions { 15 | bool readOnly; /**< No modifications to databases are allowed. */ 16 | } CBLManagerOptions; 17 | 18 | 19 | /** Top-level CouchbaseLite object; manages a collection of databases as a CouchDB server does. 20 | A CBLManager and all the objects descending from it may only be used on a single 21 | thread. To work with databases on another thread, copy the database manager (by calling 22 | -copy) and use the copy on the other thread. */ 23 | @interface CBLManager : NSObject 24 | 25 | /** A shared per-process instance. This should only be used on the main thread. */ 26 | + (instancetype) sharedInstance; 27 | 28 | /** Returns YES if the given name is a valid database name. 29 | (Only the characters in "abcdefghijklmnopqrstuvwxyz0123456789_$()+-/" are allowed.) */ 30 | + (BOOL) isValidDatabaseName: (NSString*)name __attribute__((nonnull)); 31 | 32 | /** The default directory to use for a CBLManager. This is in the Application Support directory. */ 33 | + (NSString*) defaultDirectory; 34 | 35 | /** Default initializer. Stores databases in the default directory. */ 36 | - (instancetype) init; 37 | 38 | /** Initializes a CouchbaseLite manager that stores its data at the given path. 39 | @param directory Path to data directory. If it doesn't already exist it will be created. 40 | @param options If non-NULL, a pointer to options (read-only and no-replicator). 41 | @param outError On return, the error if any. */ 42 | - (instancetype) initWithDirectory: (NSString*)directory 43 | options: (const CBLManagerOptions*)options 44 | error: (NSError**)outError __attribute__((nonnull(1))); 45 | 46 | /** Creates a copy of this CBLManager, which can be used on a different thread. */ 47 | - (instancetype) copy; 48 | 49 | /** Releases all resources used by the CBLManager instance and closes all its databases. */ 50 | - (void) close; 51 | 52 | /** The root directory of this manager (as specified at initialization time.) */ 53 | @property (readonly) NSString* directory; 54 | 55 | #pragma mark - DATABASES: 56 | 57 | /** Returns the database with the given name, creating it if it didn't already exist. 58 | Multiple calls with the same name will return the same CBLDatabase instance. 59 | NOTE: Database names may not contain capital letters! */ 60 | - (CBLDatabase*) databaseNamed: (NSString*)name 61 | error: (NSError**)outError __attribute__((nonnull(1))); 62 | 63 | /** Returns the database with the given name, or nil if it doesn't exist. 64 | Multiple calls with the same name will return the same CBLDatabase instance. */ 65 | - (CBLDatabase*) existingDatabaseNamed: (NSString*)name 66 | error: (NSError**)outError __attribute__((nonnull(1))); 67 | 68 | /** Same as -existingDatabaseNamed:. Enables "[]" access in Xcode 4.4+ */ 69 | - (CBLDatabase*) objectForKeyedSubscript: (NSString*)key __attribute__((nonnull)); 70 | 71 | /** An array of the names of all existing databases. */ 72 | @property (readonly) NSArray* allDatabaseNames; 73 | 74 | /** Replaces or installs a database from a file. 75 | This is primarily used to install a canned database on first launch of an app, in which case you should first check .exists to avoid replacing the database if it exists already. The canned database would have been copied into your app bundle at build time. 76 | @param databaseName The name of the database to replace. 77 | @param databasePath Path of the database file that should replace it. 78 | @param attachmentsPath Path of the associated attachments directory, or nil if there are no attachments. 79 | @param outError If an error occurs, it will be stored into this parameter on return. 80 | @return YES if the database was copied, NO if an error occurred. */ 81 | - (BOOL) replaceDatabaseNamed: (NSString*)databaseName 82 | withDatabaseFile: (NSString*)databasePath 83 | withAttachments: (NSString*)attachmentsPath 84 | error: (NSError**)outError __attribute__((nonnull(1,2))); 85 | 86 | #pragma mark - CONCURRENCY: 87 | 88 | /** The dispatch queue used to serialize access to the database manager (and its child objects.) 89 | Setting this is optional: by default the objects are bound to the thread on which the database 90 | manager was instantiated. By setting a dispatch queue, you can call the objects from within that 91 | queue no matter what the underlying thread is, and notifications will be posted on that queue 92 | as well. */ 93 | @property (strong) dispatch_queue_t dispatchQueue; 94 | 95 | /** Runs the block asynchronously on the database manager's dispatch queue or thread. 96 | Unlike the rest of the API, this can be called from any thread, and provides a limited form 97 | of multithreaded access to Couchbase Lite. */ 98 | - (void) doAsync: (void (^)())block; 99 | 100 | /** Asynchronously dispatches a block to run on a background thread. The block will be given a 101 | CBLDatabase instance to use; it must use that database instead of any CBL objects that are 102 | in use on the surrounding code's thread. Otherwise thread-safety will be violated, and 103 | Really Bad Things that are intermittent and hard to debug can happen. 104 | (Note: Unlike most of the API, this method is thread-safe.) */ 105 | - (void) backgroundTellDatabaseNamed: (NSString*)dbName to: (void (^)(CBLDatabase*))block; 106 | 107 | #pragma mark - OTHER API: 108 | 109 | /** The base URL of the database manager's REST API. You can access this URL within this process, 110 | using NSURLConnection or other APIs that use that (such as XMLHTTPRequest inside a WebView), 111 | but it isn't available outside the process. 112 | This method is only available if you've linked with the CouchbaseLiteListener framework. */ 113 | @property (readonly) NSURL* internalURL; 114 | 115 | /** Enables Couchbase Lite logging of the given type, process-wide. A partial list of types is here: 116 | http://docs.couchbase.com/couchbase-lite/cbl-ios/#useful-logging-channels 117 | It's usually more convenient to enable logging via command-line args, as discussed on that 118 | same page; but in some environments you may not have access to the args, or may want to use 119 | other criteria to enable logging. */ 120 | + (void) enableLogging: (NSString*)type; 121 | 122 | @property (readonly, nonatomic) NSMutableDictionary* customHTTPHeaders; 123 | 124 | @end 125 | 126 | 127 | /** Returns the version of Couchbase Lite */ 128 | extern NSString* CBLVersion( void ); 129 | 130 | /** NSError domain used for HTTP status codes returned by a lot of Couchbase Lite APIs -- 131 | for example code 404 is "not found", 403 is "forbidden", etc. */ 132 | extern NSString* const CBLHTTPErrorDomain; 133 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLModel.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 8/26/11. 6 | // Copyright (c) 2011-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import "MYDynamicObject.h" 10 | #import "CBLDocument.h" 11 | @class CBLAttachment, CBLDatabase, CBLDocument; 12 | 13 | 14 | /** Generic model class for CouchbaseLite documents. 15 | There's a 1::1 mapping between these and CBLDocuments; call +modelForDocument: to get (or create) a model object for a document, and .document to get the document of a model. 16 | You should subclass this and declare properties in the subclass's @@interface. As with NSManagedObject, you don't need to implement their accessor methods or declare instance variables; simply note them as '@@dynamic' in the class @@implementation. The property value will automatically be fetched from or stored to the document, using the same name. 17 | Supported scalar types are bool, char, short, int, double. These map to JSON numbers, except 'bool' which maps to JSON 'true' and 'false'. (Use bool instead of BOOL.) 18 | Supported object types are NSString, NSNumber, NSData, NSDate, NSArray, NSDictionary, NSDecimalNumber. (NSData and NSDate are not native JSON; they will be automatically converted to/from strings in base64 and ISO date formats, respectively. NSDecimalNumber is not native JSON as well; it will be converted to/from string.) 19 | Additionally, a property's type can be a pointer to a CBLModel subclass. This provides references between model objects. The raw property value in the document must be a string whose value is interpreted as a document ID. 20 | NSArray-valued properties may be restricted to a specific item class. See the documentation of +itemClassForArrayProperty: for details. */ 21 | @interface CBLModel : MYDynamicObject 22 | 23 | /** Returns the CBLModel associated with a CBLDocument, or creates & assigns one if necessary. 24 | If the CBLDocument already has an associated model, it's returned. Otherwise a new one is instantiated. 25 | If you call this on CBLModel itself, it'll delegate to the CBLModelFactory to decide what class to instantiate; this lets you map different classes to different "type" property values, for instance. 26 | If you call this method on a CBLModel subclass, it will always instantiate an instance of that class; e.g. [MyWidgetModel modelForDocument: doc] always creates a MyWidgetModel. */ 27 | + (instancetype) modelForDocument: (CBLDocument*)document __attribute__((nonnull)); 28 | 29 | /** Creates a new "untitled" model with a new unsaved document. 30 | The document won't be written to the database until -save is called. */ 31 | - (instancetype) initWithNewDocumentInDatabase: (CBLDatabase*)database __attribute__((nonnull)); 32 | 33 | /** Creates a new "untitled" model object with no document or database at all yet. 34 | Setting its .database property will cause it to create a CBLDocument. 35 | (This method is mostly here so that NSController objects can create CBLModels.) */ 36 | - (instancetype) init; 37 | 38 | /** The document this item is associated with. Will be nil if it's new and unsaved. */ 39 | @property (readonly, retain) CBLDocument* document; 40 | 41 | /** The database the item's document belongs to. 42 | Setting this property will assign the item to a database, creating a document. 43 | Setting it to nil will delete its document from its database. */ 44 | @property (retain) CBLDatabase* database; 45 | 46 | /** Is this model new, never before saved? */ 47 | @property (readonly) bool isNew; 48 | 49 | #pragma mark - SAVING: 50 | 51 | /** Writes any changes to a new revision of the document. 52 | Returns YES without doing anything, if no changes have been made. */ 53 | - (BOOL) save: (NSError**)outError; 54 | 55 | /** Should changes be saved back to the database automatically? 56 | Defaults to NO, requiring you to call -save manually. */ 57 | @property (nonatomic) bool autosaves; 58 | 59 | /** How long to wait after the first change before auto-saving, if autosaves is true. 60 | Default value is 0.0; subclasses can override this to add a delay. */ 61 | @property (readonly) NSTimeInterval autosaveDelay; 62 | 63 | /** Does this model have unsaved changes? */ 64 | @property (readonly) bool needsSave; 65 | 66 | /** The document's current properties (including unsaved changes) in externalized JSON format. 67 | This is what will be written to the CBLDocument when the model is saved. */ 68 | - (NSDictionary*) propertiesToSave; 69 | 70 | /** Removes any changes made to properties and attachments since the last save. */ 71 | - (void) revertChanges; 72 | 73 | /** Deletes the document from the database. 74 | You can still use the model object afterwards, but it will refer to the deleted revision. */ 75 | - (BOOL) deleteDocument: (NSError**)outError; 76 | 77 | /** The time interval since the document was last changed externally (e.g. by a "pull" replication. 78 | This value can be used to highlight recently-changed objects in the UI. */ 79 | @property (readonly) NSTimeInterval timeSinceExternallyChanged; 80 | 81 | /** Bulk-saves changes to multiple model objects (which must all be in the same database). 82 | The saves are performed in one transaction, for efficiency. 83 | Any unchanged models in the array are ignored. 84 | See also: -[CBLDatabase saveAllModels:]. 85 | @param models An array of CBLModel objects, which must all be in the same database. 86 | @param outError On return, the error (if the call failed.) 87 | @return A RESTOperation that saves all changes, or nil if none of the models need saving. */ 88 | + (BOOL) saveModels: (NSArray*)models 89 | error: (NSError**)outError; 90 | 91 | /** Resets the timeSinceExternallyChanged property to zero. */ 92 | - (void) markExternallyChanged; 93 | 94 | #pragma mark - PROPERTIES & ATTACHMENTS: 95 | 96 | /** Gets a property by name. 97 | You can use this for document properties that you haven't added @@property declarations for. */ 98 | - (id) getValueOfProperty: (NSString*)property __attribute__((nonnull)); 99 | 100 | /** Sets a property by name. 101 | You can use this for document properties that you haven't added @@property declarations for. */ 102 | - (BOOL) setValue: (id)value 103 | ofProperty: (NSString*)property __attribute__((nonnull(2))); 104 | 105 | 106 | /** The names of all attachments (array of strings). 107 | This reflects unsaved changes made by creating or deleting attachments. */ 108 | @property (readonly) NSArray* attachmentNames; 109 | 110 | /** Looks up the attachment with the given name (without fetching its contents). */ 111 | - (CBLAttachment*) attachmentNamed: (NSString*)name __attribute__((nonnull)); 112 | 113 | /** Creates, updates or deletes an attachment. 114 | The attachment data will be written to the database when the model is saved. 115 | @param name The attachment name. By convention, this looks like a filename. 116 | @param mimeType The MIME type of the content. 117 | @param content The body of the attachment. If this is nil, any existing attachment with this 118 | name will be deleted. */ 119 | - (void) setAttachmentNamed: (NSString*)name 120 | withContentType: (NSString*)mimeType 121 | content: (NSData*)content __attribute__((nonnull)); 122 | 123 | /** Creates, updates or deletes an attachment whose body comes from a file. 124 | (The method takes a URL, but it must be a "file:" URL. Remote resources are not supported.) 125 | The file need only be readable. It won't be moved or altered in any way. 126 | The attachment data will be copied from the file into the database when the model is saved. 127 | The file needs to be preserved until then, but afterwards it can safely be deleted. 128 | @param name The attachment name. By convention, this looks like a filename. 129 | @param mimeType The MIME type of the content. 130 | @param fileURL The URL of a local file whose contents should be copied into the attachment. 131 | If this is nil, any existing attachment with this name will be deleted.*/ 132 | - (void) setAttachmentNamed: (NSString*)name 133 | withContentType: (NSString*)mimeType 134 | contentURL: (NSURL*)fileURL __attribute__((nonnull)); 135 | 136 | /** Deletes (in memory) any existing attachment with the given name. 137 | The attachment will be deleted from the database at the same time as property changes are saved. */ 138 | - (void) removeAttachmentNamed: (NSString*)name __attribute__((nonnull)); 139 | 140 | 141 | #pragma mark - PROTECTED (FOR SUBCLASSES TO OVERRIDE) 142 | 143 | /** Designated initializer. Do not call directly except from subclass initializers; to create a new instance call +modelForDocument: instead. 144 | @param document The document. Nil if this is created new (-init was called). */ 145 | - (instancetype) initWithDocument: (CBLDocument*)document; 146 | 147 | /** The document ID to use when creating a new document. 148 | Default is nil, which means to assign no ID (the server will assign one). */ 149 | - (NSString*) idForNewDocumentInDatabase: (CBLDatabase*)db __attribute__((nonnull)); 150 | 151 | /** Called when the model's properties are reloaded from the document. 152 | This happens both when initialized from a document, and after an external change. */ 153 | - (void) didLoadFromDocument; 154 | 155 | /** Returns the database in which to look up the document ID of a model-valued property. 156 | Defaults to the same database as the receiver's document. You should override this if a document property contains the ID of a document in a different database. */ 157 | - (CBLDatabase*) databaseForModelProperty: (NSString*)propertyName __attribute__((nonnull)); 158 | 159 | /** Marks the model as having unsaved content, ensuring that it will get saved after a short interval (if .autosaves is YES) or when -save or -[CBLDatabase saveAllModels] are called. 160 | You don't normally need to call this, since property setters call it for you. One case where you'd need to call it is if you want to manage mutable state in your own properties and not store the changes into dynamic properties until it's time to save. In that case you should also override -propertiesToSave and update the dynamic properties accordingly before chaining to the superclass method. */ 161 | - (void) markNeedsSave; 162 | 163 | /** Called while saving a document, before building the new revision's dictionary. 164 | This method can modify property values if it wants to. */ 165 | - (void) willSave: (NSSet*)changedPropertyNames; 166 | 167 | /** If you want properties to be saved in the document when it's deleted (in addition to the required "_deleted":true) override this method to return those properties. 168 | This is called by -deleteDocument:. The default implementation returns {"_deleted":true}. */ 169 | - (NSDictionary*) propertiesToSaveForDeletion; 170 | 171 | /** General method for declaring the class of items in a property of type NSArray*. 172 | Given the property name, the override should return a class that all items must inherit from, 173 | or nil if the property is untyped. Supported classes are CBLModel (or any subclass), 174 | NSData, NSDate, NSDecimalNumber, and any JSON-compatible class (NSNumber, NSString, etc.) 175 | If you don't recognize the property name you should call the superclass method. 176 | 177 | The default implementation of this method checks for the existence of a class method with 178 | selector of the form +propertyItemClass where 'property' is replaced by the actual property 179 | name. If such a method exists it is called, and must return a class. 180 | 181 | In general you'll find it easier to implement the '+propertyItemClass' method(s) rather 182 | than overriding this one. */ 183 | + (Class) itemClassForArrayProperty: (NSString*)property; 184 | 185 | @end 186 | 187 | 188 | 189 | /** CBLDatabase methods for use with CBLModel. */ 190 | @interface CBLDatabase (CBLModel) 191 | 192 | /** All CBLModels associated with this database whose needsSave is true. */ 193 | @property (readonly) NSArray* unsavedModels; 194 | 195 | /** Saves changes to all CBLModels associated with this database whose needsSave is true. */ 196 | - (BOOL) saveAllModels: (NSError**)outError; 197 | 198 | /** Immediately runs any pending autosaves for all CBLModels associated with this database. 199 | (On iOS, this will automatically be called when the application is about to quit or go into the 200 | background. On Mac OS it is NOT called automatically.) */ 201 | - (BOOL) autosaveAllModels: (NSError**)outError; 202 | 203 | @end 204 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLModelFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLModelFactory.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 11/22/11. 6 | // Copyright (c) 2011-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import "CBLDatabase.h" 10 | @class CBLDocument; 11 | 12 | 13 | /** A configurable mapping from CBLDocument to CBLModel. 14 | It associates a model class with a value of the document's "type" property. */ 15 | @interface CBLModelFactory : NSObject 16 | 17 | /** Returns a global shared CBLModelFactory that's consulted by all databases. 18 | Mappings registered in this instance will be used as a fallback by all other instances if they don't have their own. */ 19 | + (instancetype) sharedInstance; 20 | 21 | /** Given a document, attempts to return a CBLModel for it. 22 | If the document's modelObject property is set, it returns that value. 23 | If the document's "type" property has been registered, instantiates the associated class. 24 | Otherwise returns nil. */ 25 | - (id) modelForDocument: (CBLDocument*)document __attribute__((nonnull)); 26 | 27 | /** Associates a value of the "type" property with a CBLModel subclass. 28 | @param classOrName Either a CBLModel subclass, or its class name as an NSString. 29 | @param type The value value of a document's "type" property that should indicate this class. */ 30 | - (void) registerClass: (id)classOrName 31 | forDocumentType: (NSString*)type __attribute__((nonnull(2))); 32 | 33 | /** Returns the appropriate CBLModel subclass for this document. 34 | The default implementation just passes the document's "type" property value to -classForDocumentType:, but subclasses could override this to use different properties (or even the document ID) to decide. */ 35 | - (Class) classForDocument: (CBLDocument*)document __attribute__((nonnull)); 36 | 37 | /** Looks up the CBLModel subclass that's been registered for a document type. */ 38 | - (Class) classForDocumentType: (NSString*)type __attribute__((nonnull)); 39 | 40 | @end 41 | 42 | 43 | @interface CBLDatabase (CBLModelFactory) 44 | 45 | /** The CBLModel factory object to be used by this database. 46 | Every database has its own instance by default, but you can set this property to use a different one -- either to use a custom subclass, or to share a factory among multiple databases, or both. */ 47 | @property (retain) CBLModelFactory* modelFactory; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLQuery+FullTextSearch.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLQuery+FullTextSearch.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 9/21/13. 6 | // Copyright (c) 2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import "CBLQuery.h" 10 | 11 | 12 | /** CBLQuery interface for full-text searches. 13 | To use this, the view's map function must have emitted full-text strings as keys 14 | using the CBLTextKey() function. */ 15 | @interface CBLQuery (FullTextSearch) 16 | 17 | /** Query string for a full-text search; works only if the view's map function has triggered full- 18 | text indexing by emitting strings wrapped by CBLTextKey(). 19 | The query string syntax is described in http://sqlite.org/fts3.html#section_3 . 20 | The query rows produced by this search will be instances of CBLFullTextQueryRow. 21 | **NOTE:** Full-text views have no keys, so the key-related query properties will be ignored. 22 | They also can't be reduced or grouped, so those properties are ignored too. */ 23 | @property (copy) NSString* fullTextQuery; 24 | 25 | /** If set to YES, the query will collect snippets of the text surrounding each match, available 26 | via the CBLFullTextQueryRow's -snippetWithWordStart:wordEnd: method. */ 27 | @property BOOL fullTextSnippets; 28 | 29 | /** If YES (the default) the full-text query result rows will be sorted by (approximate) relevance. 30 | If set to NO, the rows will be returned in the order the documents were added to the database, 31 | i.e. essentially unordered; this is somewhat faster, so it can be useful if you don't care 32 | about the ordering of the rows. */ 33 | @property BOOL fullTextRanking; 34 | 35 | @end 36 | 37 | 38 | 39 | /** A result row from a full-text query. 40 | A CBLQuery with its .fullTextQuery property set will produce CBLFullTextQueryRows. */ 41 | @interface CBLFullTextQueryRow : CBLQueryRow 42 | 43 | /** The text emitted when the view was indexed, which contains the match. */ 44 | @property (readonly) NSString* fullText; 45 | 46 | /** Returns a short substring of the full text containing at least some of the matched words. 47 | This is useful to display in search results, and is faster than fetching the .fullText. 48 | NOTE: The "fullTextSnippets" property of the CBLQuery must be set to YES to enable this; 49 | otherwise the result will be nil. 50 | @param wordStart A delimiter that will be inserted before every instance of a match. 51 | @param wordEnd A delimiter that will be inserted after every instance of a match. */ 52 | - (NSString*) snippetWithWordStart: (NSString*)wordStart 53 | wordEnd: (NSString*)wordEnd; 54 | 55 | /** The number of matches found in the fullText. */ 56 | @property (readonly) NSUInteger matchCount; 57 | 58 | /** The character range in the fullText of a particular match. */ 59 | - (NSRange) textRangeOfMatch: (NSUInteger)matchNumber; 60 | 61 | /** The search term matched by a particular match. Search terms are the individual words (or 62 | quoted phrases) in the full-text search expression. They're numbered starting from 0, except 63 | terms prefixed with "NOT" are skipped. (Details at http://sqlite.org/fts3.html#matchable ) */ 64 | - (NSUInteger) termIndexOfMatch: (NSUInteger)matchNumber; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLQuery+Geo.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLQuery+Geo.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 9/23/13. 6 | // Copyright (c) 2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import "CBLQuery.h" 10 | #import "CBLGeometry.h" 11 | 12 | 13 | /** CBLQuery interface for geo-queries. 14 | To use this, the view's map function must have emitted geometries (points, rects, etc.) 15 | as keys using the functions CBLGeoPointKey(), CBLGeoRectKey(), or CBLGeoJSONKey(). */ 16 | @interface CBLQuery (Geo) 17 | 18 | /** The geometric bounding box to search. Setting this property causes the query to 19 | search geometries rather than keys. */ 20 | @property CBLGeoRect boundingBox; 21 | 22 | @end 23 | 24 | 25 | /** A result row from a CouchbaseLite geo-query. 26 | A CBLQuery with its .boundingBox property set will produce CBLGeoQueryRows. */ 27 | @interface CBLGeoQueryRow : CBLQueryRow 28 | 29 | /** The row's geo bounding box in native form. 30 | If the emitted geo object was a point, the boundingBox's min and max will be equal. 31 | Note: The coordinates may have slight round-off error, because SQLite internally stores bounding 32 | boxes as 32-bit floats, but the coordinates are always rounded outwards -- making the bounding 33 | box slightly larger -- to avoid false negatives in searches. */ 34 | @property (readonly, nonatomic) CBLGeoRect boundingBox; 35 | 36 | /** The GeoJSON object emitted as the key of the emit() call by the map function. 37 | The format is a parsed GeoJSON point or polygon; see http://geojson.org/geojson-spec */ 38 | @property (readonly) NSDictionary* geometry; 39 | 40 | /** The GeoJSON object type of the row's geometry. 41 | Usually @"Point" or @"Rectangle", but may be another type if the emitted key was GeoJSON. 42 | (The "Rectangle" type is not standard GeoJSON.) */ 43 | @property (readonly, nonatomic) NSString* geometryType; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLQuery.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLQuery.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/18/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class CBLDatabase, CBLDocument; 12 | @class CBLLiveQuery, CBLQueryEnumerator, CBLQueryRow; 13 | 14 | 15 | typedef enum { 16 | kCBLAllDocs, /**< Normal behavior for all-docs query */ 17 | kCBLIncludeDeleted, /**< Will include rows for deleted documents */ 18 | kCBLShowConflicts, /**< Rows will indicate conflicting revisions */ 19 | kCBLOnlyConflicts /**< Will _only_ return rows for docs in conflict */ 20 | } CBLAllDocsMode; 21 | 22 | 23 | /** Query options to allow out-of-date results to be returned in return for faster queries. */ 24 | typedef enum { 25 | kCBLUpdateIndexBefore, /**< Always update index if needed before querying (default) */ 26 | kCBLUpdateIndexNever, /**< Don't update the index; results may be out of date */ 27 | kCBLUpdateIndexAfter /**< Update index _after_ querying (results may still be out of date) */ 28 | } CBLIndexUpdateMode; 29 | 30 | 31 | /** Represents a query of a CouchbaseLite 'view', or of a view-like resource like _all_documents. */ 32 | @interface CBLQuery : NSObject 33 | 34 | /** The database that contains this view. */ 35 | @property (readonly) CBLDatabase* database; 36 | 37 | /** The maximum number of rows to return. Defaults to 'unlimited' (UINT_MAX). */ 38 | @property NSUInteger limit; 39 | 40 | /** The number of initial rows to skip. Default value is 0. 41 | Should only be used with small values. For efficient paging, use startKey and limit.*/ 42 | @property NSUInteger skip; 43 | 44 | /** Should the rows be returned in descending key order? Default value is NO. */ 45 | @property BOOL descending; 46 | 47 | /** If non-nil, the key value to start at. */ 48 | @property (copy) id startKey; 49 | 50 | /** If non-nil, the key value to end after. */ 51 | @property (copy) id endKey; 52 | 53 | /** If non-nil, the document ID to start at. 54 | (Useful if the view contains multiple identical keys, making .startKey ambiguous.) */ 55 | @property (copy) NSString* startKeyDocID; 56 | 57 | /** If non-nil, the document ID to end at. 58 | (Useful if the view contains multiple identical keys, making .endKey ambiguous.) */ 59 | @property (copy) NSString* endKeyDocID; 60 | 61 | /** Determines whether or when the view index is updated. By default, the index will be updated 62 | if necessary before the query runs -- this guarantees up-to-date results but can cause a 63 | delay. The "Never" mode skips updating the index, so it's faster but can return out of date 64 | results. The "After" mode is a compromise that may return out of date results but if so will 65 | start asynchronously updating the index after the query so future results are accurate. */ 66 | @property CBLIndexUpdateMode indexUpdateMode; 67 | 68 | /** If non-nil, the query will fetch only the rows with the given keys. */ 69 | @property (copy) NSArray* keys; 70 | 71 | /** If set to YES, disables use of the reduce function. 72 | (Equivalent to setting "?reduce=false" in the REST API.) */ 73 | @property BOOL mapOnly; 74 | 75 | /** If non-zero, enables grouping of results, in views that have reduce functions. */ 76 | @property NSUInteger groupLevel; 77 | 78 | /** If set to YES, the results will include the entire document contents of the associated rows. 79 | These can be accessed via CBLQueryRow's -documentProperties property. 80 | This slows down the query, but can be a good optimization if you know you'll need the entire 81 | contents of each document. */ 82 | @property BOOL prefetch; 83 | 84 | /** Changes the behavior of a query created by -queryAllDocuments. 85 | * In mode kCBLAllDocs (the default), the query simply returns all non-deleted documents. 86 | * In mode kCBLIncludeDeleted, it also returns deleted documents. 87 | * In mode kCBLShowConflicts, the .conflictingRevisions property of each row will return the 88 | conflicting revisions, if any, of that document. 89 | * In mode kCBLOnlyConflicts, _only_ documents in conflict will be returned. 90 | (This mode is especially useful for use with a CBLLiveQuery, so you can be notified of 91 | conflicts as they happen, i.e. when they're pulled in by a replication.) */ 92 | @property CBLAllDocsMode allDocsMode; 93 | 94 | /** Sends the query to the server and returns an enumerator over the result rows (Synchronous). 95 | Note: In a CBLLiveQuery you should access the .rows property instead. */ 96 | - (CBLQueryEnumerator*) run: (NSError**)outError; 97 | 98 | /** Starts an asynchronous query. Returns immediately, then calls the onComplete block when the 99 | query completes, passing it the row enumerator (or an error). */ 100 | - (void) runAsync: (void (^)(CBLQueryEnumerator*, NSError*))onComplete __attribute__((nonnull)); 101 | 102 | /** Returns a live query with the same parameters. */ 103 | - (CBLLiveQuery*) asLiveQuery; 104 | 105 | @end 106 | 107 | 108 | /** A CBLQuery subclass that automatically refreshes the result rows every time the database changes. 109 | All you need to do is use KVO to observe changes to the .rows property. */ 110 | @interface CBLLiveQuery : CBLQuery 111 | 112 | /** Starts observing database changes. The .rows property will now update automatically. (You 113 | usually don't need to call this yourself, since accessing or observing the .rows property will 114 | call -start for you.) */ 115 | - (void) start; 116 | 117 | /** Stops observing database changes. Calling -start or .rows will restart it. */ 118 | - (void) stop; 119 | 120 | /** The current query results; this updates as the database changes, and can be observed using KVO. 121 | Its value will be nil until the initial asynchronous query finishes. */ 122 | @property (readonly, retain) CBLQueryEnumerator* rows; 123 | 124 | /** Blocks until the intial asynchronous query finishes. 125 | After this call either .rows or .lastError will be non-nil. */ 126 | - (BOOL) waitForRows; 127 | 128 | /** If non-nil, the error of the last execution of the query. 129 | If nil, the last execution of the query was successful. */ 130 | @property (readonly) NSError* lastError; 131 | 132 | @end 133 | 134 | 135 | /** Enumerator on a CBLQuery's result rows. 136 | The objects returned are instances of CBLQueryRow. */ 137 | @interface CBLQueryEnumerator : NSEnumerator 138 | 139 | /** The number of rows returned in this enumerator */ 140 | @property (readonly) NSUInteger count; 141 | 142 | /** The database's current sequenceNumber at the time the view was generated. */ 143 | @property (readonly) UInt64 sequenceNumber; 144 | 145 | /** YES if the database has changed since the view was generated. */ 146 | @property (readonly) BOOL stale; 147 | 148 | /** The next result row. This is the same as -nextObject but with a checked return type. */ 149 | - (CBLQueryRow*) nextRow; 150 | 151 | /** Random access to a row in the result */ 152 | - (CBLQueryRow*) rowAtIndex: (NSUInteger)index; 153 | 154 | /** Resets the enumeration so the next call to -nextObject or -nextRow will return the first row. */ 155 | - (void) reset; 156 | 157 | @end 158 | 159 | 160 | /** A result row from a CouchbaseLite view query. 161 | Full-text and geo queries return subclasses -- see CBLFullTextQueryRow and CBLGeoQueryRow. */ 162 | @interface CBLQueryRow : NSObject 163 | 164 | /** The row's key: this is the first parameter passed to the emit() call that generated the row. */ 165 | @property (readonly) id key; 166 | 167 | /** The row's value: this is the second parameter passed to the emit() call that generated the row. */ 168 | @property (readonly) id value; 169 | 170 | /** The ID of the document described by this view row. 171 | This is not necessarily the same as the document that caused this row to be emitted; see the discussion of the .sourceDocumentID property for details. */ 172 | @property (readonly) NSString* documentID; 173 | 174 | /** The ID of the document that caused this view row to be emitted. 175 | This is the value of the "id" property of the JSON view row. 176 | It will be the same as the .documentID property, unless the map function caused a related document to be linked by adding an "_id" key to the emitted value; in this case .documentID will refer to the linked document, while sourceDocumentID always refers to the original document. 177 | In a reduced or grouped query the value will be nil, since the rows don't correspond to 178 | individual documents. */ 179 | @property (readonly) NSString* sourceDocumentID; 180 | 181 | /** The revision ID of the document this row was mapped from. */ 182 | @property (readonly) NSString* documentRevisionID; 183 | 184 | @property (readonly) CBLDatabase* database; 185 | 186 | /** The document this row was mapped from. 187 | This will be nil if a grouping was enabled in the query, because then the result rows don't correspond to individual documents. */ 188 | @property (readonly) CBLDocument* document; 189 | 190 | /** The properties of the document this row was mapped from. 191 | To get this, you must have set the .prefetch property on the query; else this will be nil. 192 | (You can still get the document properties via the .document property, of course. But it 193 | takes a separate call to the database. So if you're doing it for every row, using 194 | .prefetch and .documentProperties is faster.) */ 195 | @property (readonly) NSDictionary* documentProperties; 196 | 197 | /** If this row's key is an array, returns the item at that index in the array. 198 | If the key is not an array, index=0 will return the key itself. 199 | If the index is out of range, returns nil. */ 200 | - (id) keyAtIndex: (NSUInteger)index; 201 | 202 | /** Convenience for use in keypaths. Returns the key at the given index. */ 203 | @property (readonly) id key0, key1, key2, key3; 204 | 205 | /** The database sequence number of the associated doc/revision. */ 206 | @property (readonly) UInt64 sequenceNumber; 207 | 208 | /** Returns all conflicting revisions of the document, as an array of CBLRevision, or nil if the 209 | document is not in conflict. 210 | The first object in the array will be the default "winning" revision that shadows the others. 211 | This is only valid in an allDocuments query whose allDocsMode is set to kCBLShowConflicts 212 | or kCBLOnlyConflicts; otherwise it returns nil. */ 213 | @property (readonly) NSArray* conflictingRevisions; 214 | 215 | @end 216 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLReplication.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLReplication.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/22/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDatabase; 11 | @protocol CBLAuthenticator; 12 | 13 | 14 | /** Describes the current status of a replication. */ 15 | typedef enum { 16 | kCBLReplicationStopped, /**< The replication is finished or hit a fatal error. */ 17 | kCBLReplicationOffline, /**< The remote host is currently unreachable. */ 18 | kCBLReplicationIdle, /**< Continuous replication is caught up and waiting for more changes.*/ 19 | kCBLReplicationActive /**< The replication is actively transferring data. */ 20 | } CBLReplicationStatus; 21 | 22 | 23 | /** A 'push' or 'pull' replication between a local and a remote database. 24 | Replications can be one-shot or continuous. */ 25 | @interface CBLReplication : NSObject 26 | 27 | /** The local database being replicated to/from. */ 28 | @property (nonatomic, readonly) CBLDatabase* localDatabase; 29 | 30 | /** The URL of the remote database. */ 31 | @property (nonatomic, readonly) NSURL* remoteURL; 32 | 33 | /** Does the replication pull from (as opposed to push to) the target? */ 34 | @property (nonatomic, readonly) BOOL pull; 35 | 36 | 37 | #pragma mark - OPTIONS: 38 | 39 | /** Should the target database be created if it doesn't already exist? (Defaults to NO). */ 40 | @property (nonatomic) BOOL createTarget; 41 | 42 | /** Should the replication operate continuously? (Defaults to NO). 43 | A continuous replication keeps running (with 'idle' status) after updating the target database. 44 | It monitors the source database and copies new revisions as soon as they're available. 45 | Continuous replications keep running until the app quits or they're stopped. */ 46 | @property (nonatomic) bool continuous; 47 | 48 | /** Name of an optional filter function to run on the source server. 49 | Only documents for which the function returns true are replicated. 50 | * For a pull replication, the name looks like "designdocname/filtername". 51 | * For a push replication, use the name under which you registered the filter with the CBLDatabase. */ 52 | @property (nonatomic, copy) NSString* filter; 53 | 54 | /** Parameters to pass to the filter function. 55 | Should map strings to strings. */ 56 | @property (nonatomic, copy) NSDictionary* filterParams; 57 | 58 | /** List of Sync Gateway channel names to filter by; a nil value means no filtering, i.e. all 59 | available channels will be synced. 60 | Only valid for pull replications whose source database is on a Couchbase Sync Gateway server. 61 | (This is a convenience that just reads or changes the values of .filter and .query_params.) */ 62 | @property (nonatomic, copy) NSArray* channels; 63 | 64 | /** Sets the documents to specify as part of the replication. */ 65 | @property (copy) NSArray *documentIDs; 66 | 67 | /** Extra HTTP headers to send in all requests to the remote server. 68 | Should map strings (header names) to strings. */ 69 | @property (nonatomic, copy) NSDictionary* headers; 70 | 71 | /** Specifies which class of network the replication will operate over. 72 | Default value is nil, which means replicate over all networks. 73 | Set to "WiFi" (or "!Cell") to replicate only over WiFi, 74 | or to "Cell" (or "!WiFi") to replicate only over cellular. */ 75 | @property (nonatomic, copy) NSString* network; 76 | 77 | /** An optional JSON-compatible dictionary of extra properties for the replicator. */ 78 | @property (nonatomic, copy) NSDictionary* customProperties; 79 | 80 | 81 | #pragma mark - AUTHENTICATION: 82 | 83 | /** An object that knows how to authenticate with a remote server. 84 | CBLAuthenticator is an opaque protocol; instances can be created by calling the factory methods 85 | of the class of the same name. */ 86 | @property id authenticator; 87 | 88 | /** The credential (generally username+password) to use to authenticate to the remote database. 89 | This can either come from the URL itself (if it's of the form "http://user:pass@example.com") 90 | or be stored in the NSURLCredentialStore, which is a wrapper around the Keychain. */ 91 | @property (nonatomic, strong) NSURLCredential* credential; 92 | 93 | /** OAuth parameters that the replicator should use when authenticating to the remote database. 94 | Keys in the dictionary should be "consumer_key", "consumer_secret", "token", "token_secret", 95 | and optionally "signature_method". */ 96 | @property (nonatomic, copy) NSDictionary* OAuth; 97 | 98 | /** The base URL of the remote server, for use as the "origin" parameter when requesting Persona or 99 | Facebook authentication. */ 100 | @property (readonly) NSURL* personaOrigin; 101 | 102 | /** Adds a cookie to the shared NSHTTPCookieStorage that will be sent to the remote server. This 103 | is useful if you've obtained a session cookie through some external means and need to tell the 104 | replicator to send it for authentication purposes. 105 | This method constructs an NSHTTPCookie from the given parameters, as well as the remote server 106 | URL's host, port and path. 107 | If you already have an NSHTTPCookie object for the remote server, you can simply add it to the 108 | sharedHTTPCookieStorage yourself. 109 | If you have a "Set-Cookie:" response header, you can use NSHTTPCookie's class methods to parse 110 | it to a cookie object, then add it to the sharedHTTPCookieStorage. */ 111 | - (void) setCookieNamed: (NSString*)name 112 | withValue: (NSString*)value 113 | path: (NSString*)path 114 | expirationDate: (NSDate*)expirationDate 115 | secure: (BOOL)secure; 116 | 117 | /** Deletes the named cookie from the shared NSHTTPCookieStorage for the remote server's URL. */ 118 | -(void)deleteCookieNamed:(NSString *)name; 119 | 120 | /** Adds additional SSL root certificates to be trusted by the replicator, or entirely overrides the 121 | OS's default list of trusted root certs. 122 | @param certs An array of SecCertificateRefs of root certs that should be trusted. Most often 123 | these will be self-signed certs, but they might also be the roots of nonstandard CAs. 124 | @param onlyThese If NO, the given certs are appended to the system's built-in list of trusted 125 | root certs; if YES, it replaces them (so *only* the given certs will be trusted.) */ 126 | + (void) setAnchorCerts: (NSArray*)certs onlyThese: (BOOL)onlyThese; 127 | 128 | #pragma mark - STATUS: 129 | 130 | /** Starts the replication, asynchronously. 131 | Has no effect if the replication is already running. 132 | You can monitor its progress by observing the kCBLReplicationChangeNotification it sends, 133 | or by using KVO to observe its .running, .status, .error, .total and .completed properties. */ 134 | - (void) start; 135 | 136 | /** Stops replication, asynchronously. 137 | Has no effect if the replication is not running. */ 138 | - (void) stop; 139 | 140 | /** Restarts a running replication. 141 | Has no effect if the replication is not running. */ 142 | - (void) restart; 143 | 144 | /** The replication's current state, one of {stopped, offline, idle, active}. */ 145 | @property (nonatomic, readonly) CBLReplicationStatus status; 146 | 147 | /** YES while the replication is running, NO if it's stopped. 148 | Note that a continuous replication never actually stops; it only goes idle waiting for new 149 | data to appear. */ 150 | @property (nonatomic, readonly) BOOL running; 151 | 152 | /** The error status of the replication, or nil if there have not been any errors since it started. */ 153 | @property (nonatomic, readonly, retain) NSError* lastError; 154 | 155 | /** The number of completed changes processed, if the task is active, else 0 (observable). */ 156 | @property (nonatomic, readonly) unsigned completedChangesCount; 157 | 158 | /** The total number of changes to be processed, if the task is active, else 0 (observable). */ 159 | @property (nonatomic, readonly) unsigned changesCount; 160 | 161 | 162 | #ifdef CBL_DEPRECATED 163 | @property (nonatomic, copy) NSString* facebookEmailAddress 164 | __attribute__((deprecated("set authenticator property instead"))); 165 | - (BOOL) registerFacebookToken: (NSString*)token forEmailAddress: (NSString*)email 166 | __attribute__((deprecated("set authenticator property instead"))); 167 | - (BOOL) registerPersonaAssertion: (NSString*)assertion 168 | __attribute__((deprecated("set authenticator property instead"))); 169 | @property (nonatomic, copy) NSString* personaEmailAddress 170 | __attribute__((deprecated("set authenticator property instead"))); 171 | #endif 172 | 173 | @end 174 | 175 | 176 | /** This notification is posted by a CBLReplication when any of these properties change: 177 | {status, running, error, completed, total}. It's often more convenient to observe this 178 | notification rather than observing each property individually. */ 179 | extern NSString* const kCBLReplicationChangeNotification; 180 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLRevision.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLRevision.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/17/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDocument, CBLDatabase, CBLAttachment, CBLSavedRevision, CBLUnsavedRevision; 11 | 12 | 13 | /** A revision of a CBLDocument. 14 | This is the abstract base class of CBLSavedRevision (existing revisions) and CBLNewRevision 15 | (revisions yet to be saved). */ 16 | @interface CBLRevision : NSObject 17 | 18 | /** The document this is a revision of. */ 19 | @property (readonly, weak) CBLDocument* document; 20 | 21 | /** The database this revision's document belongs to. */ 22 | @property (readonly) CBLDatabase* database; 23 | 24 | /** Does this revision mark the deletion of its document? 25 | (In other words, does it have a "_deleted" property?) */ 26 | @property (readonly) BOOL isDeletion; 27 | 28 | /** Does this revision mark the deletion or removal (from available channels) of its document ? 29 | (In other words, does it have a "_deleted_ or "_removed" property?) */ 30 | @property (readonly) BOOL isGone; 31 | 32 | /** The ID of this revision. Will be nil if this is an unsaved CBLNewRevision. */ 33 | @property (readonly) NSString* revisionID; 34 | 35 | /** The revision this one is a child of. */ 36 | @property (readonly) CBLSavedRevision* parentRevision; 37 | 38 | /** The ID of the parentRevision. */ 39 | @property (readonly) NSString* parentRevisionID; 40 | 41 | /** Returns the ancestry of this revision as an array of CBLRevisions, in chronological order. 42 | Older revisions are NOT guaranteed to have their properties available. */ 43 | - (NSArray*) getRevisionHistory: (NSError**)outError; 44 | 45 | /** The revision's contents as parsed from JSON. 46 | Keys beginning with "_" are defined and reserved by CouchbaseLite; others are app-specific. 47 | The first call to this method may need to fetch the properties from disk, but subsequent calls 48 | are very cheap. */ 49 | @property (readonly, copy) NSDictionary* properties; 50 | 51 | /** The user-defined properties, without the ones reserved by CouchbaseLite. 52 | This is based on -properties, with every key whose name starts with "_" removed. */ 53 | @property (readonly, copy) NSDictionary* userProperties; 54 | 55 | /** Shorthand for [self.properties objectForKey: key]. */ 56 | - (id) propertyForKey: (NSString*)key __attribute__((nonnull)); 57 | 58 | /** Same as -propertyForKey:. Enables "[]" access in Xcode 4.4+ */ 59 | - (id) objectForKeyedSubscript: (NSString*)key __attribute__((nonnull)); 60 | 61 | #pragma mark ATTACHMENTS 62 | 63 | /** The names of all attachments (an array of strings). */ 64 | @property (readonly) NSArray* attachmentNames; 65 | 66 | /** Looks up the attachment with the given name (without fetching its contents yet). */ 67 | - (CBLAttachment*) attachmentNamed: (NSString*)name __attribute__((nonnull)); 68 | 69 | /** All attachments, as CBLAttachment objects. */ 70 | @property (readonly) NSArray* attachments; 71 | 72 | @end 73 | 74 | 75 | 76 | /** An existing revision of a CBLDocument. Most of its API is inherited from CBLRevisionBase. */ 77 | @interface CBLSavedRevision : CBLRevision 78 | 79 | /** Are this revision's properties available? They may not be if the revision is an ancestor and 80 | either the database has been compacted, or the revision was replicated from another db. */ 81 | @property (readonly) BOOL propertiesAvailable; 82 | 83 | /** Creates a new mutable child revision whose properties and attachments are initially identical 84 | to this one's, which you can modify and then save. */ 85 | - (CBLUnsavedRevision*) createRevision; 86 | 87 | /** Creates and saves a new revision with the given properties. 88 | This will fail with a 412 error if the receiver is not the current revision of the document. */ 89 | - (CBLSavedRevision*) createRevisionWithProperties: (NSDictionary*)properties 90 | error: (NSError**)outError; 91 | 92 | /** Deletes the document by creating a new deletion-marker revision. */ 93 | - (CBLSavedRevision*) deleteDocument: (NSError**)outError; 94 | 95 | @end 96 | 97 | 98 | 99 | /** An unsaved new revision. Most of its API is inherited from CBLRevisionBase. */ 100 | @interface CBLUnsavedRevision : CBLRevision 101 | 102 | // These properties are overridden to be settable: 103 | @property (readwrite) BOOL isDeletion; 104 | @property (readwrite, copy) NSMutableDictionary* properties; 105 | @property (readwrite, copy) NSDictionary* userProperties; 106 | - (void) setObject: (id)object forKeyedSubscript: (NSString*)key; 107 | 108 | /** Saves the new revision to the database. 109 | This will fail with a 412 error if its parent (the revision it was created from) is not the current revision of the document. 110 | Afterwards you should use the returned CBLSavedRevision instead of this object. 111 | @return A new CBLSavedRevision representing the saved form of the revision. */ 112 | - (CBLSavedRevision*) save: (NSError**)outError; 113 | 114 | /** A special variant of -save: that always adds the revision, even if its parent is not the 115 | current revision of the document. 116 | This can be used to resolve conflicts, or to create them. If you're not certain that's what you 117 | want to do, you should use the regular -save: method instead. */ 118 | - (CBLSavedRevision*) saveAllowingConflict: (NSError**)outError; 119 | 120 | /** Creates, updates or deletes an attachment. 121 | The attachment data will be written to the database when the revision is saved. 122 | @param name The attachment name. By convention, this looks like a filename. 123 | @param mimeType The MIME type of the content. 124 | @param content The body of the attachment. */ 125 | - (void) setAttachmentNamed: (NSString*)name 126 | withContentType: (NSString*)mimeType 127 | content: (NSData*)content; 128 | 129 | /** Creates, updates or deletes an attachment whose body comes from a file. 130 | (The method takes a URL, but it must be a "file:" URL. Remote resources are not supported.) 131 | The file need only be readable. It won't be moved or altered in any way. 132 | The attachment data will be copied from the file into the database when the revision is saved. 133 | The file needs to be preserved until then, but afterwards it can safely be deleted. 134 | @param name The attachment name. By convention, this looks like a filename. 135 | @param mimeType The MIME type of the content. 136 | @param fileURL The URL of a local file whose contents should be copied into the attachment. */ 137 | - (void) setAttachmentNamed: (NSString*)name 138 | withContentType: (NSString*)mimeType 139 | contentURL: (NSURL*)fileURL; 140 | 141 | /** Removes the attachment with the given name. 142 | When this revision is saved, it won't include the attachment. However, the attachment will 143 | still be present in the parent revision, until the database is next compacted. */ 144 | - (void) removeAttachmentNamed: (NSString*)name; 145 | 146 | @end 147 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLUITableSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLUITableSource.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 8/2/11. 6 | // Copyright 2011-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDocument, CBLLiveQuery, CBLQueryRow; 11 | 12 | /** A UITableView data source driven by a CBLLiveQuery. 13 | It populates the table rows from the query rows, and automatically updates the table as the 14 | query results change when the database is updated. 15 | A CBLUITableSource can be created in a nib. If so, its tableView outlet should be wired up to 16 | the UITableView it manages, and the table view's dataSource outlet should be wired to it. */ 17 | @interface CBLUITableSource : NSObject = 60000) 19 | , UIDataSourceModelAssociation 20 | #endif 21 | > 22 | /** The table view to manage. */ 23 | @property (nonatomic, retain) IBOutlet UITableView* tableView; 24 | 25 | /** The query whose rows will be displayed in the table. */ 26 | @property (retain) CBLLiveQuery* query; 27 | 28 | /** Rebuilds the table from the query's current .rows property. */ 29 | -(void) reloadFromQuery; 30 | 31 | 32 | #pragma mark Row Accessors: 33 | 34 | /** The current array of CBLQueryRows being used as the data source for the table. */ 35 | @property (nonatomic, readonly) NSArray* rows; 36 | 37 | /** Convenience accessor to get the row object for a given table row index. */ 38 | - (CBLQueryRow*) rowAtIndex: (NSUInteger)index; 39 | 40 | /** Convenience accessor to find the index path of the row with a given document. */ 41 | - (NSIndexPath*) indexPathForDocument: (CBLDocument*)document __attribute__((nonnull)); 42 | 43 | /** Convenience accessor to return the query row at a given index path. */ 44 | - (CBLQueryRow*) rowAtIndexPath: (NSIndexPath*)path __attribute__((nonnull)); 45 | 46 | /** Convenience accessor to return the document at a given index path. */ 47 | - (CBLDocument*) documentAtIndexPath: (NSIndexPath*)path __attribute__((nonnull)); 48 | 49 | 50 | #pragma mark Displaying The Table: 51 | 52 | /** If non-nil, specifies the property name of the query row's value that will be used for the table row's visible label. 53 | If the row's value is not a dictionary, or if the property doesn't exist, the property will next be looked up in the document's properties. 54 | If this doesn't meet your needs for labeling rows, you should implement -couchTableSource:willUseCell:forRow: in the table's delegate. */ 55 | @property (copy) NSString* labelProperty; 56 | 57 | 58 | #pragma mark Editing The Table: 59 | 60 | /** Is the user allowed to delete rows by UI gestures? (Defaults to YES.) */ 61 | @property (nonatomic) BOOL deletionAllowed; 62 | 63 | /** Deletes the documents at the given row indexes, animating the removal from the table. */ 64 | - (BOOL) deleteDocumentsAtIndexes: (NSArray*)indexPaths 65 | error: (NSError**)outError __attribute__((nonnull(1))); 66 | 67 | /** Asynchronously deletes the given documents, animating the removal from the table. */ 68 | - (BOOL) deleteDocuments: (NSArray*)documents 69 | error: (NSError**)outError __attribute__((nonnull(1))); 70 | 71 | @end 72 | 73 | 74 | /** Additional methods for the table view's delegate, that will be invoked by the CBLUITableSource. */ 75 | @protocol CBLUITableDelegate 76 | @optional 77 | 78 | /** Allows delegate to return its own custom cell, just like -tableView:cellForRowAtIndexPath:. 79 | If this returns nil the table source will create its own cell, as if this method were not implemented. */ 80 | - (UITableViewCell *)couchTableSource:(CBLUITableSource*)source 81 | cellForRowAtIndexPath:(NSIndexPath *)indexPath; 82 | 83 | /** Called after the query's results change, before the table view is reloaded. */ 84 | - (void)couchTableSource:(CBLUITableSource*)source 85 | willUpdateFromQuery:(CBLLiveQuery*)query; 86 | 87 | /** Called after the query's results change to update the table view. If this method is not implemented by the delegate, reloadData is called on the table view.*/ 88 | - (void)couchTableSource:(CBLUITableSource*)source 89 | updateFromQuery:(CBLLiveQuery*)query 90 | previousRows:(NSArray *)previousRows; 91 | 92 | /** Called from -tableView:cellForRowAtIndexPath: just before it returns, giving the delegate a chance to customize the new cell. */ 93 | - (void)couchTableSource:(CBLUITableSource*)source 94 | willUseCell:(UITableViewCell*)cell 95 | forRow:(CBLQueryRow*)row; 96 | 97 | /** Called when the user wants to delete a row. 98 | If the delegate implements this method, it will be called *instead of* the 99 | default behavior of deleting the associated document. 100 | @param source The CBLUITableSource 101 | @param row The query row corresponding to the row to delete 102 | @return True if the row was deleted, false if not. */ 103 | - (bool)couchTableSource:(CBLUITableSource*)source 104 | deleteRow:(CBLQueryRow*)row; 105 | 106 | /** Called upon failure of a document deletion triggered by the user deleting a row. */ 107 | - (void)couchTableSource:(CBLUITableSource*)source 108 | deleteFailed:(NSError*)error; 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CBLView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLView.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 6/19/12. 6 | // Copyright (c) 2012-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CBLDatabase, CBLQuery; 11 | 12 | 13 | typedef void (^CBLMapEmitBlock)(id key, id value); 14 | 15 | 16 | /** A "map" function called when a document is to be added to a view. 17 | @param doc The contents of the document being analyzed. 18 | @param emit A block to be called to add a key/value pair to the view. Your block can call it zero, one or multiple times. */ 19 | typedef void (^CBLMapBlock)(NSDictionary* doc, CBLMapEmitBlock emit); 20 | 21 | /** A "reduce" function called to summarize the results of a view. 22 | @param keys An array of keys to be reduced (or nil if this is a rereduce). 23 | @param values A parallel array of values to be reduced, corresponding 1::1 with the keys. 24 | @param rereduce YES if the input values are the results of previous reductions. 25 | @return The reduced value; almost always a scalar or small fixed-size object. */ 26 | typedef id (^CBLReduceBlock)(NSArray* keys, NSArray* values, BOOL rereduce); 27 | 28 | 29 | #define MAPBLOCK(BLOCK) ^(NSDictionary* doc, void (^emit)(id key, id value)){BLOCK} 30 | #define REDUCEBLOCK(BLOCK) ^id(NSArray* keys, NSArray* values, BOOL rereduce){BLOCK} 31 | 32 | 33 | /** Returns a special value that, when emitted as a key, causes the given text to be indexed with 34 | the full-text indexer. Used inside a map block, like so: `emit(CBLTextKey(longText), value);` */ 35 | FOUNDATION_EXTERN id CBLTextKey(NSString* text); 36 | 37 | /** An external object that knows how to map source code of some sort into executable functions. */ 38 | @protocol CBLViewCompiler 39 | - (CBLMapBlock) compileMapFunction: (NSString*)mapSource language: (NSString*)language; 40 | - (CBLReduceBlock) compileReduceFunction: (NSString*)reduceSource language: (NSString*)language; 41 | @end 42 | 43 | 44 | /** A "view" in a CouchbaseLite database -- essentially a persistent index managed by map/reduce. 45 | The view can be queried using a CBLQuery. */ 46 | @interface CBLView : NSObject 47 | 48 | /** The database that owns this view. */ 49 | @property (readonly) CBLDatabase* database; 50 | 51 | /** The name of the view. */ 52 | @property (readonly) NSString* name; 53 | 54 | /** The map function that controls how index rows are created from documents. */ 55 | @property (readonly) CBLMapBlock mapBlock; 56 | 57 | /** The optional reduce function, which aggregates together multiple rows. */ 58 | @property (readonly) CBLReduceBlock reduceBlock; 59 | 60 | /** Defines a view's functions. 61 | The view's definition is given as an Objective-C block (or NULL to delete the view). The body of the block should call the 'emit' block (passed in as a paramter) for every key/value pair it wants to write to the view. 62 | Since the function itself is obviously not stored in the database (only a unique string idenfitying it), you must re-define the view on every launch of the app! If the database needs to rebuild the view but the function hasn't been defined yet, it will fail and the view will be empty, causing weird problems later on. 63 | It is very important that this block be a law-abiding map function! As in other languages, it must be a "pure" function, with no side effects, that always emits the same values given the same input document. That means that it should not access or change any external state; be careful, since blocks make that so easy that you might do it inadvertently! 64 | The block may be called on any thread, or on multiple threads simultaneously. This won't be a problem if the code is "pure" as described above, since it will as a consequence also be thread-safe. 65 | @param mapBlock The map function. The MAPBLOCK macro makes it easier to declare this. 66 | @param reduceBlock The reduce function, or nil for none. The REDUCEBLOCK macro makes it easier to declare this. 67 | @param version An arbitrary string that will be stored persistently along with the index. Usually a string literal like @"1". If you subsequently change the functionality of the map or reduce function, change this string as well: the call will detect that it's different and will clear the index so it can be rebuilt by the new function. 68 | @return YES if the view was updated and the index cleared; NO if the version stayed the same. */ 69 | - (BOOL) setMapBlock: (CBLMapBlock)mapBlock 70 | reduceBlock: (CBLReduceBlock)reduceBlock 71 | version: (NSString*)version __attribute__((nonnull(1,3))); 72 | 73 | /** Defines a view that has no reduce function. 74 | See -setMapBlock:reduceBlock:version: for more details. */ 75 | - (BOOL) setMapBlock: (CBLMapBlock)mapBlock 76 | version: (NSString*)version __attribute__((nonnull(1,2))); 77 | 78 | /** Is the view's index currently out of date? */ 79 | @property (readonly) BOOL stale; 80 | 81 | /** The last sequence number indexed so far. */ 82 | @property (readonly) SInt64 lastSequenceIndexed; 83 | 84 | /** Deletes the view's persistent index. It will be regenerated on the next query. */ 85 | - (void) deleteIndex; 86 | 87 | /** Deletes the view, persistently. */ 88 | - (void) deleteView; 89 | 90 | /** Creates a new query object for this view. The query can be customized and then executed. */ 91 | - (CBLQuery*) createQuery; 92 | 93 | /** Utility function to use in reduce blocks. Totals an array of NSNumbers. */ 94 | + (NSNumber*) totalValues: (NSArray*)values; 95 | 96 | /** Registers an object that can compile map/reduce functions from source code. */ 97 | + (void) setCompiler: (id)compiler; 98 | 99 | /** The registered object, if any, that can compile map/reduce functions from source code. */ 100 | + (id) compiler; 101 | 102 | @end 103 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/CouchbaseLite.h: -------------------------------------------------------------------------------- 1 | // 2 | // CouchbaseLite.h 3 | // CouchbaseLite 4 | // 5 | // Created by Jens Alfke on 12/2/11. 6 | // Copyright (c) 2011-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 9 | // except in compliance with the License. You may obtain a copy of the License at 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // Unless required by applicable law or agreed to in writing, software distributed under the 12 | // License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 13 | // either express or implied. See the License for the specific language governing permissions 14 | // and limitations under the License. 15 | 16 | 17 | #define CBL_DEPRECATED // Enable deprecated methods. 18 | 19 | #import "CBLManager.h" 20 | #import "CBLDatabase.h" 21 | #import "CBLDatabaseChange.h" 22 | #import "CBLDocument.h" 23 | #import "CBLRevision.h" 24 | #import "CBLAttachment.h" 25 | #import "CBLView.h" 26 | #import "CBLQuery.h" 27 | #import "CBLQuery+FullTextSearch.h" 28 | #import "CBLQuery+Geo.h" 29 | #import "CBLReplication.h" 30 | #import "CBLModel.h" 31 | #import "CBLModelFactory.h" 32 | #import "CBLJSON.h" 33 | 34 | #if TARGET_OS_IPHONE 35 | #import "CBLUITableSource.h" 36 | #endif 37 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Headers/MYDynamicObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // MYDynamicObject.h 3 | // MYUtilities 4 | // 5 | // Created by Jens Alfke on 8/6/09. 6 | // Copyright 2009 Jens Alfke. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** A generic class with runtime support for dynamic properties. 13 | You can subclass this and declare properties in the subclass without needing to implement them or make instance variables; simply note them as '@@dynamic' in the @@implementation. 14 | The dynamic accessors will be bridged to calls to -getValueOfProperty: and setValue:ofProperty:, allowing you to easily store property values in an NSDictionary or other container. */ 15 | @interface MYDynamicObject : NSObject 16 | 17 | /** Returns the names of all properties defined in this class and superclasses up to MYDynamicObject. */ 18 | + (NSSet*) propertyNames; 19 | 20 | /** Returns the value of a named property. 21 | This method will only be called for properties that have been declared in the class's @@interface using @@property. 22 | You must override this method -- the base implementation just raises an exception. */ 23 | - (id) getValueOfProperty: (NSString*)property; 24 | 25 | /** Sets the value of a named property. 26 | This method will only be called for properties that have been declared in the class's @@interface using @@property, and are not declared readonly. 27 | You must override this method -- the base implementation just raises an exception. 28 | @return YES if the property was set, NO if it isn't settable; an exception will be raised. 29 | Default implementation returns NO. */ 30 | - (BOOL) setValue: (id)value ofProperty: (NSString*)property; 31 | 32 | 33 | // FOR SUBCLASSES TO CALL: 34 | 35 | /** Given the name of an object-valued property, returns the class of the property's value. 36 | Returns nil if the property doesn't exist, or if its type isn't an object pointer or is 'id'. */ 37 | + (Class) classOfProperty: (NSString*)propertyName; 38 | 39 | + (NSString*) getterKey: (SEL)sel; 40 | + (NSString*) setterKey: (SEL)sel; 41 | 42 | // ADVANCED STUFF FOR SUBCLASSES TO OVERRIDE: 43 | 44 | + (IMP) impForGetterOfProperty: (NSString*)property ofClass: (Class)propertyClass; 45 | + (IMP) impForSetterOfProperty: (NSString*)property ofClass: (Class)propertyClass; 46 | + (IMP) impForGetterOfProperty: (NSString*)property ofType: (const char*)propertyType; 47 | + (IMP) impForSetterOfProperty: (NSString*)property ofType: (const char*)propertyType; 48 | 49 | @end 50 | 51 | /** Given an Objective-C class object, a property name, and a BOOL for whether the property should be readwrite, 52 | return YES if a property with the name exists , NO otherwise. 53 | If setter argument is YES but property is declared readonly, also returns NO. 54 | Information about the property is returned by reference: the subclass of cls that declares the property, 55 | and the property string part of the property attributes string. 56 | */ 57 | BOOL MYGetPropertyInfo(Class cls, 58 | NSString *propertyName, 59 | BOOL setter, 60 | Class *declaredInClass, 61 | const char* *propertyType); 62 | 63 | 64 | /** Given an Objective-C property type string, returns the property type as a Class object, 65 | or nil if a class does not apply or no such property is present. 66 | See Property Type String section of the Objective-C Runtime Programming Guide 67 | for more information about the format of the string. */ 68 | Class MYClassFromType(const char* propertyType); 69 | -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLite.framework/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-couchbaselite-cheatsheet/b137653164c7dad6ecae01506c4b955003cb25d7/swift-couchbaselite/CouchbaseLite.framework/Info.plist -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLiteListener.framework/CouchbaseLiteListener: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-couchbaselite-cheatsheet/b137653164c7dad6ecae01506c4b955003cb25d7/swift-couchbaselite/CouchbaseLiteListener.framework/CouchbaseLiteListener -------------------------------------------------------------------------------- /swift-couchbaselite/CouchbaseLiteListener.framework/Headers/CBLListener.h: -------------------------------------------------------------------------------- 1 | // 2 | // CBLListener.h 3 | // CouchbaseLiteListener 4 | // 5 | // Created by Jens Alfke on 12/29/11. 6 | // Copyright (c) 2011-2013 Couchbase, Inc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @class CBLHTTPServer, CBLManager; 12 | 13 | 14 | /** A simple HTTP server that provides remote access to the CouchbaseLite REST API. */ 15 | @interface CBLListener : NSObject 16 | 17 | /** Initializes a CBLListener. 18 | @param manager The CBLManager whose databases to serve. 19 | @param port The TCP port number to listen on. Use 0 to automatically pick an available port (you can get the port number after the server starts by getting the .port property.) */ 20 | - (instancetype) initWithManager: (CBLManager*)manager port: (UInt16)port; 21 | 22 | /** The TCP port number that the listener is listening on. 23 | If the listener has not yet started, this will return 0. */ 24 | @property (readonly) UInt16 port; 25 | 26 | 27 | /** The Bonjour service name and type to advertise as. 28 | @param name The service name; this can be arbitrary but is generally the device user's name. An empty string will be mapped to the device's name. 29 | @param type The service type; the type of a generic HTTP server is "_http._tcp." but you should use something more specific. */ 30 | - (void) setBonjourName: (NSString*)name type: (NSString*)type; 31 | 32 | /** Bonjour metadata associated with the service. Changes will be visible almost immediately. 33 | The keys are NSStrings and values are NSData. Total size should be kept small (under 1kbyte if possible) as this data is multicast over UDP. */ 34 | @property (copy) NSDictionary* TXTRecordDictionary; 35 | 36 | /** The URL at which the listener can be reached. */ 37 | @property (readonly) NSURL* URL; 38 | 39 | 40 | /** If set to YES, remote requests will not be allowed to make any changes to the server or its databases. */ 41 | @property BOOL readOnly; 42 | 43 | /** If set to YES, all requests will be required to authenticate. 44 | Setting the .passwords property automatically enables this.*/ 45 | @property BOOL requiresAuth; 46 | 47 | /** Security realm string to return in authentication challenges. */ 48 | @property (copy) NSString* realm; 49 | 50 | /** Sets user names and passwords for authentication. 51 | @param passwords A dictionary mapping user names to passwords. */ 52 | - (void) setPasswords: (NSDictionary*)passwords; 53 | 54 | /** Returns the password assigned to a user name, or nil if the name is not recognized. */ 55 | - (NSString*) passwordForUser: (NSString*)username; 56 | 57 | 58 | /** Private key and certificate to use for incoming SSL connections. 59 | If nil (the default) SSL connections are not accepted. */ 60 | @property (nonatomic) SecIdentityRef SSLIdentity; 61 | 62 | /** Supporting certificates to use along with the SSLIdentity. Necessary if the SSL certificate 63 | is not directly signed by a CA cert known to the OS. */ 64 | @property (strong, nonatomic) NSArray* SSLExtraCertificates; 65 | 66 | 67 | /** Starts the listener. */ 68 | - (BOOL) start: (NSError**)outError; 69 | 70 | /** Stops the listener. */ 71 | - (void) stop; 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /swift-couchbaselite/bridging-header.h: -------------------------------------------------------------------------------- 1 | 2 | #import "CouchbaseLiteListener.framework/Headers/CBLListener.h" 3 | #import "CouchbaseLite.framework/Headers/CBLAttachment.h" 4 | #import "CouchbaseLite.framework/Headers/CBLAuthenticator.h" 5 | #import "CouchbaseLite.framework/Headers/CBLDatabase.h" 6 | #import "CouchbaseLite.framework/Headers/CBLDatabaseChange.h" 7 | #import "CouchbaseLite.framework/Headers/CBLDocument.h" 8 | #import "CouchbaseLite.framework/Headers/CBLGeometry.h" 9 | #import "CouchbaseLite.framework/Headers/CBLJSON.h" 10 | #import "CouchbaseLite.framework/Headers/CBLManager.h" 11 | #import "CouchbaseLite.framework/Headers/CBLModel.h" 12 | #import "CouchbaseLite.framework/Headers/CBLModelFactory.h" 13 | #import "CouchbaseLite.framework/Headers/CBLQuery.h" 14 | #import "CouchbaseLite.framework/Headers/CBLQuery+FullTextSearch.h" 15 | #import "CouchbaseLite.framework/Headers/CBLQuery+Geo.h" 16 | #import "CouchbaseLite.framework/Headers/CBLReplication.h" 17 | #import "CouchbaseLite.framework/Headers/CBLRevision.h" 18 | #import "CouchbaseLite.framework/Headers/CBLUITableSource.h" 19 | #import "CouchbaseLite.framework/Headers/CBLView.h" 20 | #import "CouchbaseLite.framework/Headers/CouchbaseLite.h" 21 | #import "CouchbaseLite.framework/Headers/MYDynamicObject.h" -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C03424C019867E6A009A5300 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03424BF19867E6A009A5300 /* AppDelegate.swift */; }; 11 | C03424C219867E6A009A5300 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C03424C119867E6A009A5300 /* Images.xcassets */; }; 12 | C03424CE19867E6A009A5300 /* swift_couchbaseliteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03424CD19867E6A009A5300 /* swift_couchbaseliteTests.swift */; }; 13 | C0628F2E19867EDE002BEE98 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0628F2D19867EDE002BEE98 /* MainViewController.swift */; }; 14 | C0628F3019867F9B002BEE98 /* CouchbaseLite.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F2F19867F9B002BEE98 /* CouchbaseLite.framework */; }; 15 | C0628F3219867FA4002BEE98 /* CouchbaseLiteListener.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F3119867FA4002BEE98 /* CouchbaseLiteListener.framework */; }; 16 | C0628F34198680C4002BEE98 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F33198680C4002BEE98 /* CFNetwork.framework */; }; 17 | C0628F36198680CF002BEE98 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F35198680CF002BEE98 /* Security.framework */; }; 18 | C0628F38198680D7002BEE98 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F37198680D7002BEE98 /* SystemConfiguration.framework */; }; 19 | C0628F3A198680E4002BEE98 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F39198680E4002BEE98 /* libsqlite3.dylib */; }; 20 | C0628F3C198680EA002BEE98 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = C0628F3B198680EA002BEE98 /* libz.dylib */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | C03424C819867E6A009A5300 /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = C03424B219867E6A009A5300 /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = C03424B919867E6A009A5300; 29 | remoteInfo = "swift-couchbaselite"; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | C03424BA19867E6A009A5300 /* swift-couchbaselite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "swift-couchbaselite.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | C03424BE19867E6A009A5300 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | C03424BF19867E6A009A5300 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | C03424C119867E6A009A5300 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 38 | C03424C719867E6A009A5300 /* swift-couchbaseliteTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "swift-couchbaseliteTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | C03424CC19867E6A009A5300 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | C03424CD19867E6A009A5300 /* swift_couchbaseliteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swift_couchbaseliteTests.swift; sourceTree = ""; }; 41 | C0628F2D19867EDE002BEE98 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 42 | C0628F2F19867F9B002BEE98 /* CouchbaseLite.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CouchbaseLite.framework; sourceTree = ""; }; 43 | C0628F3119867FA4002BEE98 /* CouchbaseLiteListener.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CouchbaseLiteListener.framework; sourceTree = ""; }; 44 | C0628F33198680C4002BEE98 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 45 | C0628F35198680CF002BEE98 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 46 | C0628F37198680D7002BEE98 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 47 | C0628F39198680E4002BEE98 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 48 | C0628F3B198680EA002BEE98 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 49 | C0628F3E19868328002BEE98 /* bridging-header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "bridging-header.h"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | C03424B719867E6A009A5300 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | C0628F3C198680EA002BEE98 /* libz.dylib in Frameworks */, 58 | C0628F3A198680E4002BEE98 /* libsqlite3.dylib in Frameworks */, 59 | C0628F38198680D7002BEE98 /* SystemConfiguration.framework in Frameworks */, 60 | C0628F36198680CF002BEE98 /* Security.framework in Frameworks */, 61 | C0628F34198680C4002BEE98 /* CFNetwork.framework in Frameworks */, 62 | C0628F3219867FA4002BEE98 /* CouchbaseLiteListener.framework in Frameworks */, 63 | C0628F3019867F9B002BEE98 /* CouchbaseLite.framework in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | C03424C419867E6A009A5300 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | C03424B119867E6A009A5300 = { 78 | isa = PBXGroup; 79 | children = ( 80 | C0628F3E19868328002BEE98 /* bridging-header.h */, 81 | C0628F3B198680EA002BEE98 /* libz.dylib */, 82 | C0628F39198680E4002BEE98 /* libsqlite3.dylib */, 83 | C0628F37198680D7002BEE98 /* SystemConfiguration.framework */, 84 | C0628F35198680CF002BEE98 /* Security.framework */, 85 | C0628F33198680C4002BEE98 /* CFNetwork.framework */, 86 | C0628F3119867FA4002BEE98 /* CouchbaseLiteListener.framework */, 87 | C0628F2F19867F9B002BEE98 /* CouchbaseLite.framework */, 88 | C03424BC19867E6A009A5300 /* swift-couchbaselite */, 89 | C03424CA19867E6A009A5300 /* swift-couchbaseliteTests */, 90 | C03424BB19867E6A009A5300 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | C03424BB19867E6A009A5300 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | C03424BA19867E6A009A5300 /* swift-couchbaselite.app */, 98 | C03424C719867E6A009A5300 /* swift-couchbaseliteTests.xctest */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | C03424BC19867E6A009A5300 /* swift-couchbaselite */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | C03424BF19867E6A009A5300 /* AppDelegate.swift */, 107 | C0628F2D19867EDE002BEE98 /* MainViewController.swift */, 108 | C03424C119867E6A009A5300 /* Images.xcassets */, 109 | C03424BD19867E6A009A5300 /* Supporting Files */, 110 | ); 111 | path = "swift-couchbaselite"; 112 | sourceTree = ""; 113 | }; 114 | C03424BD19867E6A009A5300 /* Supporting Files */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | C03424BE19867E6A009A5300 /* Info.plist */, 118 | ); 119 | name = "Supporting Files"; 120 | sourceTree = ""; 121 | }; 122 | C03424CA19867E6A009A5300 /* swift-couchbaseliteTests */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | C03424CD19867E6A009A5300 /* swift_couchbaseliteTests.swift */, 126 | C03424CB19867E6A009A5300 /* Supporting Files */, 127 | ); 128 | path = "swift-couchbaseliteTests"; 129 | sourceTree = ""; 130 | }; 131 | C03424CB19867E6A009A5300 /* Supporting Files */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | C03424CC19867E6A009A5300 /* Info.plist */, 135 | ); 136 | name = "Supporting Files"; 137 | sourceTree = ""; 138 | }; 139 | /* End PBXGroup section */ 140 | 141 | /* Begin PBXNativeTarget section */ 142 | C03424B919867E6A009A5300 /* swift-couchbaselite */ = { 143 | isa = PBXNativeTarget; 144 | buildConfigurationList = C03424D119867E6A009A5300 /* Build configuration list for PBXNativeTarget "swift-couchbaselite" */; 145 | buildPhases = ( 146 | C03424B619867E6A009A5300 /* Sources */, 147 | C03424B719867E6A009A5300 /* Frameworks */, 148 | C03424B819867E6A009A5300 /* Resources */, 149 | ); 150 | buildRules = ( 151 | ); 152 | dependencies = ( 153 | ); 154 | name = "swift-couchbaselite"; 155 | productName = "swift-couchbaselite"; 156 | productReference = C03424BA19867E6A009A5300 /* swift-couchbaselite.app */; 157 | productType = "com.apple.product-type.application"; 158 | }; 159 | C03424C619867E6A009A5300 /* swift-couchbaseliteTests */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = C03424D419867E6A009A5300 /* Build configuration list for PBXNativeTarget "swift-couchbaseliteTests" */; 162 | buildPhases = ( 163 | C03424C319867E6A009A5300 /* Sources */, 164 | C03424C419867E6A009A5300 /* Frameworks */, 165 | C03424C519867E6A009A5300 /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | C03424C919867E6A009A5300 /* PBXTargetDependency */, 171 | ); 172 | name = "swift-couchbaseliteTests"; 173 | productName = "swift-couchbaseliteTests"; 174 | productReference = C03424C719867E6A009A5300 /* swift-couchbaseliteTests.xctest */; 175 | productType = "com.apple.product-type.bundle.unit-test"; 176 | }; 177 | /* End PBXNativeTarget section */ 178 | 179 | /* Begin PBXProject section */ 180 | C03424B219867E6A009A5300 /* Project object */ = { 181 | isa = PBXProject; 182 | attributes = { 183 | LastSwiftUpdateCheck = 0720; 184 | LastUpgradeCheck = 0720; 185 | ORGANIZATIONNAME = zemirco; 186 | TargetAttributes = { 187 | C03424B919867E6A009A5300 = { 188 | CreatedOnToolsVersion = 6.0; 189 | }; 190 | C03424C619867E6A009A5300 = { 191 | CreatedOnToolsVersion = 6.0; 192 | TestTargetID = C03424B919867E6A009A5300; 193 | }; 194 | }; 195 | }; 196 | buildConfigurationList = C03424B519867E6A009A5300 /* Build configuration list for PBXProject "swift-couchbaselite" */; 197 | compatibilityVersion = "Xcode 3.2"; 198 | developmentRegion = English; 199 | hasScannedForEncodings = 0; 200 | knownRegions = ( 201 | en, 202 | ); 203 | mainGroup = C03424B119867E6A009A5300; 204 | productRefGroup = C03424BB19867E6A009A5300 /* Products */; 205 | projectDirPath = ""; 206 | projectRoot = ""; 207 | targets = ( 208 | C03424B919867E6A009A5300 /* swift-couchbaselite */, 209 | C03424C619867E6A009A5300 /* swift-couchbaseliteTests */, 210 | ); 211 | }; 212 | /* End PBXProject section */ 213 | 214 | /* Begin PBXResourcesBuildPhase section */ 215 | C03424B819867E6A009A5300 /* Resources */ = { 216 | isa = PBXResourcesBuildPhase; 217 | buildActionMask = 2147483647; 218 | files = ( 219 | C03424C219867E6A009A5300 /* Images.xcassets in Resources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | C03424C519867E6A009A5300 /* Resources */ = { 224 | isa = PBXResourcesBuildPhase; 225 | buildActionMask = 2147483647; 226 | files = ( 227 | ); 228 | runOnlyForDeploymentPostprocessing = 0; 229 | }; 230 | /* End PBXResourcesBuildPhase section */ 231 | 232 | /* Begin PBXSourcesBuildPhase section */ 233 | C03424B619867E6A009A5300 /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | C03424C019867E6A009A5300 /* AppDelegate.swift in Sources */, 238 | C0628F2E19867EDE002BEE98 /* MainViewController.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | C03424C319867E6A009A5300 /* Sources */ = { 243 | isa = PBXSourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | C03424CE19867E6A009A5300 /* swift_couchbaseliteTests.swift in Sources */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | /* End PBXSourcesBuildPhase section */ 251 | 252 | /* Begin PBXTargetDependency section */ 253 | C03424C919867E6A009A5300 /* PBXTargetDependency */ = { 254 | isa = PBXTargetDependency; 255 | target = C03424B919867E6A009A5300 /* swift-couchbaselite */; 256 | targetProxy = C03424C819867E6A009A5300 /* PBXContainerItemProxy */; 257 | }; 258 | /* End PBXTargetDependency section */ 259 | 260 | /* Begin XCBuildConfiguration section */ 261 | C03424CF19867E6A009A5300 /* Debug */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ALWAYS_SEARCH_USER_PATHS = NO; 265 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 266 | CLANG_CXX_LIBRARY = "libc++"; 267 | CLANG_ENABLE_MODULES = YES; 268 | CLANG_ENABLE_OBJC_ARC = YES; 269 | CLANG_WARN_BOOL_CONVERSION = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 272 | CLANG_WARN_EMPTY_BODY = YES; 273 | CLANG_WARN_ENUM_CONVERSION = YES; 274 | CLANG_WARN_INT_CONVERSION = YES; 275 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 276 | CLANG_WARN_UNREACHABLE_CODE = YES; 277 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 278 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 279 | COPY_PHASE_STRIP = NO; 280 | ENABLE_STRICT_OBJC_MSGSEND = YES; 281 | ENABLE_TESTABILITY = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_DYNAMIC_NO_PIC = NO; 284 | GCC_OPTIMIZATION_LEVEL = 0; 285 | GCC_PREPROCESSOR_DEFINITIONS = ( 286 | "DEBUG=1", 287 | "$(inherited)", 288 | ); 289 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 297 | METAL_ENABLE_DEBUG_INFO = YES; 298 | ONLY_ACTIVE_ARCH = YES; 299 | SDKROOT = iphoneos; 300 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 301 | }; 302 | name = Debug; 303 | }; 304 | C03424D019867E6A009A5300 /* Release */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | ALWAYS_SEARCH_USER_PATHS = NO; 308 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 309 | CLANG_CXX_LIBRARY = "libc++"; 310 | CLANG_ENABLE_MODULES = YES; 311 | CLANG_ENABLE_OBJC_ARC = YES; 312 | CLANG_WARN_BOOL_CONVERSION = YES; 313 | CLANG_WARN_CONSTANT_CONVERSION = YES; 314 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 315 | CLANG_WARN_EMPTY_BODY = YES; 316 | CLANG_WARN_ENUM_CONVERSION = YES; 317 | CLANG_WARN_INT_CONVERSION = YES; 318 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 319 | CLANG_WARN_UNREACHABLE_CODE = YES; 320 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 321 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 322 | COPY_PHASE_STRIP = YES; 323 | ENABLE_NS_ASSERTIONS = NO; 324 | ENABLE_STRICT_OBJC_MSGSEND = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu99; 326 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 327 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 328 | GCC_WARN_UNDECLARED_SELECTOR = YES; 329 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 330 | GCC_WARN_UNUSED_FUNCTION = YES; 331 | GCC_WARN_UNUSED_VARIABLE = YES; 332 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 333 | METAL_ENABLE_DEBUG_INFO = NO; 334 | SDKROOT = iphoneos; 335 | VALIDATE_PRODUCT = YES; 336 | }; 337 | name = Release; 338 | }; 339 | C03424D219867E6A009A5300 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 343 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 344 | FRAMEWORK_SEARCH_PATHS = ( 345 | "$(inherited)", 346 | "$(PROJECT_DIR)", 347 | ); 348 | INFOPLIST_FILE = "swift-couchbaselite/Info.plist"; 349 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 350 | OTHER_LDFLAGS = "-ObjC"; 351 | PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; 352 | PRODUCT_NAME = "$(TARGET_NAME)"; 353 | SWIFT_OBJC_BRIDGING_HEADER = "bridging-header.h"; 354 | }; 355 | name = Debug; 356 | }; 357 | C03424D319867E6A009A5300 /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 361 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 362 | FRAMEWORK_SEARCH_PATHS = ( 363 | "$(inherited)", 364 | "$(PROJECT_DIR)", 365 | ); 366 | INFOPLIST_FILE = "swift-couchbaselite/Info.plist"; 367 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 368 | OTHER_LDFLAGS = "-ObjC"; 369 | PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | SWIFT_OBJC_BRIDGING_HEADER = "bridging-header.h"; 372 | }; 373 | name = Release; 374 | }; 375 | C03424D519867E6A009A5300 /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swift-couchbaselite.app/swift-couchbaselite"; 379 | FRAMEWORK_SEARCH_PATHS = ( 380 | "$(SDKROOT)/Developer/Library/Frameworks", 381 | "$(inherited)", 382 | ); 383 | GCC_PREPROCESSOR_DEFINITIONS = ( 384 | "DEBUG=1", 385 | "$(inherited)", 386 | ); 387 | INFOPLIST_FILE = "swift-couchbaseliteTests/Info.plist"; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 389 | METAL_ENABLE_DEBUG_INFO = YES; 390 | PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | TEST_HOST = "$(BUNDLE_LOADER)"; 393 | }; 394 | name = Debug; 395 | }; 396 | C03424D619867E6A009A5300 /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swift-couchbaselite.app/swift-couchbaselite"; 400 | FRAMEWORK_SEARCH_PATHS = ( 401 | "$(SDKROOT)/Developer/Library/Frameworks", 402 | "$(inherited)", 403 | ); 404 | INFOPLIST_FILE = "swift-couchbaseliteTests/Info.plist"; 405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 406 | METAL_ENABLE_DEBUG_INFO = NO; 407 | PRODUCT_BUNDLE_IDENTIFIER = "com.example.${PRODUCT_NAME:rfc1034identifier}"; 408 | PRODUCT_NAME = "$(TARGET_NAME)"; 409 | TEST_HOST = "$(BUNDLE_LOADER)"; 410 | }; 411 | name = Release; 412 | }; 413 | /* End XCBuildConfiguration section */ 414 | 415 | /* Begin XCConfigurationList section */ 416 | C03424B519867E6A009A5300 /* Build configuration list for PBXProject "swift-couchbaselite" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | C03424CF19867E6A009A5300 /* Debug */, 420 | C03424D019867E6A009A5300 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | C03424D119867E6A009A5300 /* Build configuration list for PBXNativeTarget "swift-couchbaselite" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | C03424D219867E6A009A5300 /* Debug */, 429 | C03424D319867E6A009A5300 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | C03424D419867E6A009A5300 /* Build configuration list for PBXNativeTarget "swift-couchbaseliteTests" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | C03424D519867E6A009A5300 /* Debug */, 438 | C03424D619867E6A009A5300 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | /* End XCConfigurationList section */ 444 | }; 445 | rootObject = C03424B219867E6A009A5300 /* Project object */; 446 | } 447 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/xcshareddata/swift-couchbaselite.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 08011A70-3A28-4045-AFD0-082BA2C58F50 9 | IDESourceControlProjectName 10 | swift-couchbaselite 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | D6368FEB1474ED071690B106997550F1026E61F3 14 | https://github.com/zemirco/swift-couchbaselite-cheatsheet.git 15 | 16 | IDESourceControlProjectPath 17 | swift-couchbaselite/swift-couchbaselite.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | D6368FEB1474ED071690B106997550F1026E61F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/zemirco/swift-couchbaselite-cheatsheet.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | D6368FEB1474ED071690B106997550F1026E61F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | D6368FEB1474ED071690B106997550F1026E61F3 36 | IDESourceControlWCCName 37 | swift-couchbaselite-cheatsheet 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/xcuserdata/zeissmirco.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-couchbaselite-cheatsheet/b137653164c7dad6ecae01506c4b955003cb25d7/swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/xcuserdata/zeissmirco.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/xcuserdata/zemirco.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zemirco/swift-couchbaselite-cheatsheet/b137653164c7dad6ecae01506c4b955003cb25d7/swift-couchbaselite/swift-couchbaselite.xcodeproj/project.xcworkspace/xcuserdata/zemirco.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/xcuserdata/zeissmirco.xcuserdatad/xcschemes/swift-couchbaselite.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/xcuserdata/zeissmirco.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swift-couchbaselite.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C03424B919867E6A009A5300 16 | 17 | primary 18 | 19 | 20 | C03424C619867E6A009A5300 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcschemes/swift-couchbaselite.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite.xcodeproj/xcuserdata/zemirco.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swift-couchbaselite.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C03424B919867E6A009A5300 16 | 17 | primary 18 | 19 | 20 | C03424C619867E6A009A5300 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swift-couchbaselite 4 | // 5 | // Created by Zeiss, Mirco on 28.07.14. 6 | // Copyright (c) 2014 zemirco. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { 17 | self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 18 | self.window!.backgroundColor = UIColor.whiteColor() 19 | self.window!.rootViewController = MainViewController() 20 | self.window!.makeKeyAndVisible() 21 | return true 22 | } 23 | 24 | func applicationWillResignActive(application: UIApplication) { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | } 28 | 29 | func applicationDidEnterBackground(application: UIApplication) { 30 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 31 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 32 | } 33 | 34 | func applicationWillEnterForeground(application: UIApplication) { 35 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 36 | } 37 | 38 | func applicationDidBecomeActive(application: UIApplication) { 39 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 40 | } 41 | 42 | func applicationWillTerminate(application: UIApplication) { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaselite/MainViewController.swift: -------------------------------------------------------------------------------- 1 | 2 | import UIKit 3 | 4 | class MainViewController: UIViewController { 5 | 6 | override func viewDidLoad() { 7 | super.viewDidLoad() 8 | 9 | // open db 10 | let manager = CBLManager.sharedInstance() 11 | 12 | do { 13 | let db = try manager.databaseNamed("mydb") 14 | 15 | // save document 16 | let properties = [ 17 | "name": "mirco", 18 | "email": "mirco.zeiss@gmail.com", 19 | "repo": "swift-couchbaselite-cheatsheet" 20 | ] 21 | 22 | let doc = db.createDocument() 23 | try doc.putProperties(properties) 24 | 25 | // Creating and initializing views 26 | let view = db.viewNamed("name") 27 | let block: CBLMapBlock = { (doc, emit) in 28 | emit(doc["name"] as! String, nil) 29 | } 30 | 31 | view.setMapBlock(block, version: "11") 32 | 33 | // Querying views 34 | let query = db.viewNamed("name").createQuery() 35 | query.keys = ["mirco"] 36 | let result = try query.run() 37 | 38 | let count = Int(result.count) 39 | 40 | for var index = 0; index < count; ++index { 41 | print(result.rowAtIndex(UInt(index)).document) 42 | } 43 | 44 | } catch { 45 | print(error) 46 | } 47 | 48 | } 49 | 50 | override func didReceiveMemoryWarning() { 51 | super.didReceiveMemoryWarning() 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaseliteTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /swift-couchbaselite/swift-couchbaseliteTests/swift_couchbaseliteTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swift_couchbaseliteTests.swift 3 | // swift-couchbaseliteTests 4 | // 5 | // Created by Zeiss, Mirco on 28.07.14. 6 | // Copyright (c) 2014 zemirco. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class swift_couchbaseliteTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------