Permalink
Browse files

Use TouchDB instead of CouchbaseMobile

  • Loading branch information...
1 parent dc2bc22 commit fbc52adce5add20a2c713373589dd00b86745875 @snej snej committed Jan 8, 2012
Showing with 32 additions and 48 deletions.
  1. +8 −12 CouchDemo.xcodeproj/project.pbxproj
  2. +24 −36 Source/DemoAppDelegate.m
@@ -17,11 +17,10 @@
27167F5813C4FA57001CC5B6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
27167F5913C4FA57001CC5B6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
27167F5A13C4FA57001CC5B6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */; };
- 27167F5B13C4FA57001CC5B6 /* Couchbase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 273A739613BE918A0078870D /* Couchbase.framework */; };
276A43C913F088B800E5743A /* ConfigViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 276A43C713F088B700E5743A /* ConfigViewController.m */; };
276A43CA13F088B800E5743A /* ConfigViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 276A43C813F088B700E5743A /* ConfigViewController.xib */; };
- 278D97C414042B5300956686 /* libstdc++.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 278D97C314042B5300956686 /* libstdc++.dylib */; };
- 2794EBFD14227F1E00A53EE2 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2794EBFC14227F1E00A53EE2 /* libz.dylib */; };
+ 278E615414BA5A2A00A0B840 /* TouchDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 278E615314BA5A2A00A0B840 /* TouchDB.framework */; };
+ 278E615614BA5A4B00A0B840 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 278E615514BA5A4B00A0B840 /* libsqlite3.dylib */; };
27962307142031E80051455D /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27962306142031E80051455D /* Security.framework */; };
279C6596140FEF9A00A0E56D /* icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 279C6595140FEF9A00A0E56D /* icon.png */; };
279C6598140FEFCF00A0E56D /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 279C6597140FEFCF00A0E56D /* icon@2x.png */; };
@@ -48,13 +47,12 @@
1D3623250D0F684500981E51 /* DemoAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoAppDelegate.m; sourceTree = "<group>"; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
27167F6113C4FA57001CC5B6 /* GrocerySync.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GrocerySync.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 273A739613BE918A0078870D /* Couchbase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Couchbase.framework; path = Frameworks/Couchbase.framework; sourceTree = SOURCE_ROOT; };
27637C011416E78D001E30CA /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
276A43C613F088B700E5743A /* ConfigViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConfigViewController.h; sourceTree = "<group>"; };
276A43C713F088B700E5743A /* ConfigViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConfigViewController.m; sourceTree = "<group>"; };
276A43C813F088B700E5743A /* ConfigViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ConfigViewController.xib; path = ../Source/ConfigViewController.xib; sourceTree = "<group>"; };
- 278D97C314042B5300956686 /* libstdc++.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libstdc++.dylib"; path = "usr/lib/libstdc++.dylib"; sourceTree = SDKROOT; };
- 2794EBFC14227F1E00A53EE2 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
+ 278E615314BA5A2A00A0B840 /* TouchDB.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TouchDB.framework; path = Frameworks/TouchDB.framework; sourceTree = "<group>"; };
+ 278E615514BA5A4B00A0B840 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; };
27962306142031E80051455D /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
279C6595140FEF9A00A0E56D /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = icon.png; path = ../icon.png; sourceTree = "<group>"; };
279C6597140FEFCF00A0E56D /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "icon@2x.png"; path = "../icon@2x.png"; sourceTree = "<group>"; };
@@ -94,10 +92,9 @@
27167F5813C4FA57001CC5B6 /* Foundation.framework in Frameworks */,
27167F5913C4FA57001CC5B6 /* UIKit.framework in Frameworks */,
27167F5A13C4FA57001CC5B6 /* CoreGraphics.framework in Frameworks */,
- 27167F5B13C4FA57001CC5B6 /* Couchbase.framework in Frameworks */,
79D0A34913DC9FE400B8F348 /* CouchCocoa.framework in Frameworks */,
- 278D97C414042B5300956686 /* libstdc++.dylib in Frameworks */,
- 2794EBFD14227F1E00A53EE2 /* libz.dylib in Frameworks */,
+ 278E615414BA5A2A00A0B840 /* TouchDB.framework in Frameworks */,
+ 278E615614BA5A4B00A0B840 /* libsqlite3.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -129,6 +126,7 @@
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
+ 278E615514BA5A4B00A0B840 /* libsqlite3.dylib */,
27637C011416E78D001E30CA /* README.md */,
080E96DDFE201D6D7F000001 /* Classes */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
@@ -170,14 +168,12 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 278E615314BA5A2A00A0B840 /* TouchDB.framework */,
79D0A34813DC9FE400B8F348 /* CouchCocoa.framework */,
- 273A739613BE918A0078870D /* Couchbase.framework */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
2892E40F0DC94CBA00A64D0F /* CoreGraphics.framework */,
27962306142031E80051455D /* Security.framework */,
- 278D97C314042B5300956686 /* libstdc++.dylib */,
- 2794EBFC14227F1E00A53EE2 /* libz.dylib */,
);
name = Frameworks;
sourceTree = "<group>";
View
@@ -20,18 +20,15 @@
#import "DemoAppDelegate.h"
#import "RootViewController.h"
-#import <Couchbase/CouchbaseMobile.h>
#import <CouchCocoa/CouchCocoa.h>
+#import <CouchCocoa/CouchTouchDBServer.h>
// The name of the database the app will use.
#define kDatabaseName @"grocery-sync"
// The default remote database URL to sync with, if the user hasn't set a different one as a pref.
//#define kDefaultSyncDbURL @"http://couchbase.iriscouch.com/grocery-sync"
-// Set this to 1 to install a pre-built database from a ".couch" resource file on first run.
-#define INSTALL_CANNED_DATABASE 0
-
// Define this to use a server at a specific URL, instead of the embedded Couchbase Mobile.
// This can be useful for debugging, since you can use the admin console (futon) to inspect
// or modify the database contents.
@@ -72,45 +69,36 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Start the Couchbase Mobile server:
// gCouchLogLevel = 1;
- [CouchbaseMobile class]; // prevents dead-stripping
- CouchEmbeddedServer* server;
+ CouchTouchDBServer* server;
#ifdef USE_REMOTE_SERVER
- server = [[CouchEmbeddedServer alloc] initWithURL: [NSURL URLWithString: USE_REMOTE_SERVER]];
+ server = [[CouchTouchDBServer alloc] initWithURL: [NSURL URLWithString: USE_REMOTE_SERVER]];
#else
- server = [[CouchEmbeddedServer alloc] init];
+ server = [[CouchTouchDBServer alloc] init];
#endif
-#if INSTALL_CANNED_DATABASE
- NSString* dbPath = [[NSBundle mainBundle] pathForResource: kDatabaseName ofType: @"couch"];
- NSAssert(dbPath, @"Couldn't find "kDatabaseName".couch");
- [server installDefaultDatabase: dbPath];
-#endif
+ if (server.error) {
+ [self showAlert: @"Couldn't start Couchbase." error: server.error fatal: YES];
+ return YES;
+ }
+
+ self.database = [server databaseNamed: kDatabaseName];
- [server start: ^{ // ... this block runs later on when the server has started up:
- if (server.error) {
- [self showAlert: @"Couldn't start Couchbase." error: server.error fatal: YES];
- return;
- }
-
- self.database = [server databaseNamed: kDatabaseName];
-
#if !INSTALL_CANNED_DATABASE && !defined(USE_REMOTE_SERVER)
- // Create the database on the first run of the app.
- NSError* error;
- if (![self.database ensureCreated: &error]) {
- [self showAlert: @"Couldn't create local database." error: error fatal: YES];
- return;
- }
+ // Create the database on the first run of the app.
+ NSError* error;
+ if (![self.database ensureCreated: &error]) {
+ [self showAlert: @"Couldn't create local database." error: error fatal: YES];
+ return YES;
+ }
#endif
-
- database.tracksChanges = YES;
-
- // Tell the RootViewController:
- RootViewController* root = (RootViewController*)navigationController.topViewController;
- [root useDatabase: database];
-
- [self removeSplash];
- }];
+
+ database.tracksChanges = YES;
+
+ // Tell the RootViewController:
+ RootViewController* root = (RootViewController*)navigationController.topViewController;
+ [root useDatabase: database];
+
+ [self removeSplash];
return YES;
}

0 comments on commit fbc52ad

Please sign in to comment.