iOS and Mac OS X Client for realtime-store
Visit Google groups for discussions and announcements.
CocoaPods is the recommended way to add GDStore to your project.
- Add these pods to your Podfile:
pod 'GDJson', :git => 'https://github.com/goodow/GDJson.git'
pod 'GDChannel', :git => 'https://github.com/goodow/GDChannel.git'
pod 'GDStore', :git => 'https://github.com/goodow/GDStore.git'
- Install the pod(s) by running
pod install
. - Include GDStore wherever you need it with
#import "GDStore.h"
.
id<GDSStore> store = [[GDSStoreImpl alloc]
initWithServerUri:@"ws://localhost:1986/channel/websocket" withOptions:nil];
void (^onLoaded)(id<GDSDocument>) = ^(id<GDSDocument> document) {
id<GDSModel> model = [document getModel];
id<GDSCollaborativeMap> root = [model getRoot];
id<GDSCollaborativeString> name = [root get:@"name"];
NSLog(@"Name: %@", [name getText]);
};
void (^opt_initializer)(id<GDSModel>) = ^(id<GDSModel> model) {
id<GDSCollaborativeMap> root = [model getRoot];
id<GDSCollaborativeString> name = [model createString:@"Larry Tin"];
[root set:@"name" value:name];
};
[store load:@"docType/docId" onLoaded:onLoaded opt_initializer:opt_initializer opt_error:nil];