
seen from United Kingdom

seen from United States

seen from Romania
seen from United States
seen from United States

seen from Türkiye

seen from Germany
seen from United States
seen from United Kingdom
seen from United States
seen from United States

seen from Austria

seen from United Kingdom

seen from Germany

seen from United States
seen from United States
seen from Türkiye

seen from Germany
seen from China

seen from United States
iAmber - Part One, Adding CouchDB to XCODE 4.2 IOS 5 Project
What is CouchDB and how do i get it.
CouchDB is a noSQL document orientated database. It stores data in a document JSON, like format, and is accessible through a RESTful JSON API. adhoc and scheme-free.
CouchDB Couchbase is a server implementation and framework that extends the Apache CouchDB. When we are talking about CouchDB, we mean Couchbase. When implementing couchdb into your iOS5 projects, you'll need to add the couchbase IOS framework to your project.
Download from the Couchbase IOS site or the GIT repo.
> git clone https://github.com/couchbaselabs/iOS-Couchbase.git couchbase
1. Adding the Framework
Drag both the couchbase and cococouch to your frameworks group folder. making sure that you app is selected under targets.
Select your project and move to the build phase.
add the libraries under Link Binary With Libraries.
1. libz.dylib
2. libstdc++.dylib
3. security.framework
add the copy Couchdb script under run scripts.
rsync -a "${SRCROOT}/Couchbase.framework/CouchbaseResources" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
check the SRCROOT/ path to Couchbase.framework to verify your path to the framework.
2. Wire the Appdelegate and start CouchDB in your project.
AppDelegate.h
#import <Couchbase/CouchbaseMobile.h>
@class CouchDatabase, RootViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate,CouchbaseDelegate>{
CouchDatabase *database; }
@property(nonatomic, retain)CouchDatabase *database;
AppDelegate.m
Set the import and define database variables.
#import <CouchCocoa/CouchCocoa.h>
// The name of the database the app will use.
#define kDatabaseName @"amber"
// Set this to 1 to install a pre-built database from a ".couch" resource file on first run.
#define INSTALL_CANNED_DATABASE 0
Now in the application didFinishLaunchingWithOptions
#ifdef USE_REMOTE_SERVER
[self performSelector: @selector(connectToServer:)
withObject: [NSURL URLWithString: USE_REMOTE_SERVER]
afterDelay: 0.0];
#else
CouchbaseMobile* couchbase = [[CouchbaseMobile alloc] init];
couchbase.delegate = self;
#if INSTALL_CANNED_DATABASE
NSString* dbPath = [[NSBundle mainBundle] pathForResource: kDatabaseName ofType: @"couch"];
NSAssert(dbPath, @"Couldn't find "kDatabaseName".couch");
[gCouchbaseMobile installDefaultDatabase: dbPath];
#endif
if (![couchbase start]) {
[self showAlert: @"Couldn't start Couchbase."
error: couchbase.error
fatal: YES];
}
#endif
Now add the connectToServer method and add the couchbaseMobile delegates
- (void)connectToServer:(NSURL*)serverURL {
NSLog(@"iAmber:amber: couchbaseMobile:didStart: <%@>", serverURL);
gCouchLogLevel = 2;
if (!database) {
// This is the first time the server has started:
CouchServer *server = [[CouchServer alloc] initWithURL: serverURL];
self.database = [server databaseNamed: kDatabaseName];
//[server release];
#if !INSTALL_CANNED_DATABASE
// Create the database on the first run of the app.
if (![[self.database GET] wait])
[[self.database create] wait];
#endif
}
database.tracksChanges = YES;
database.tracksActiveOperations = YES;
}
-(void)couchbaseMobile:(CouchbaseMobile*)couchbase didStart:(NSURL*)serverURL {
NSLog(@"Couchbase is Ready, go! %@", serverURL);
[self connectToServer:serverURL];
}
-(void)couchbaseMobile:(CouchbaseMobile*)couchbase failedToStart:(NSError*)error {
NSAssert(NO, @"Couchbase failed to initialize: %@", error);
}
When you run your project in the simulator you'll get couchbase server started and a log entries to verify the database creation.
I'll be putting together iAmber as a CouchDB, IOS5 Tutorial over the next few weeks.
First up will be adding the CouchDB framework to your xcode project. Then we will talk about storyboarding the xcode 4.2 way. Storing data to your Couchdb as well as your cloud.
The application iAmber is about keeping a current record about your child. Current photo, age, etc. Things that you could easily pass to a police officer if your child went missing.
You'll be able to follow along in the Git Repo, as we build the app that we will distribute for free in the app store on completion.