doc/client-objc.txt in rhoconnect-3.0.4 vs doc/client-objc.txt in rhoconnect-3.0.5

- old
+ new

@@ -39,29 +39,29 @@ Do the following steps to add `<rhoconnect-client>/objectivec/RhoConnectClient.xcodeproj` as a dependency so that the RhoConnectClient library will link with your project. 1. Drag and drop `<rhoconnect-client>/ObjectiveC/RhoConnectClient.xcodeproj` from the Finder into Groups & Files for your Xcode project. RhoConnectClient.xcodeproj should now appear in Groups & Files. -<img src="rhoconnect-objc-client-tutorial/rhoconnectclient-groupfile.png" alt="RhoConnectClient in Groups & Files" /> +<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-objc-client-tutorial/rhoconnectclient-groupfile.png" alt="RhoConnectClient in Groups & Files" /> 2. Under Groups and Files, open the Targets icon. 3. Right-click on your project-named target. 4. Choose Get Info, then click on the General tab. 5. In Direct Dependencies, click the + button. 6. Choose the dependency from RhoConnectClient.xcodeproj. -<img src="rhoconnect-objc-client-tutorial/direct-dependency.png" alt="RhoConnectClient Direct Dependency" /> +<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-objc-client-tutorial/direct-dependency.png" alt="RhoConnectClient Direct Dependency" /> ### Adding Xcode Libraries Do the following steps to add libraries: 1. Under Groups & Files, right-click on your project (the name at the top of the list). 2. Select Add->Existing Frameworks from the popup menu. 3. Add the following to your project: `libstdc++6.dylib, libsqlite3.dylib, libz.dylib, CFNetwork.framework`. -<img src="rhoconnect-objc-client-tutorial/add-frameworks.png" alt="Add Frameworks" /> +<img src="http://rhodocs.s3.amazonaws.com/rhoconnect-objc-client-tutorial/add-frameworks.png" alt="Add Frameworks" /> ### Adding Schema Files Do the following steps to add schema files to your Copy Bundle Resources build phase: 1. Copy the folder `<rhodes>/platform/shared/db/res/db` into your Xcode project folder. @@ -97,14 +97,14 @@ Call init for RhoConnectClient to initialize your client. :::cplusplus sclient = [[RhoConnectClient alloc] init]; -Set up an NSArray containing the models for your client. +Set up an NSMutableArray containing the models for your client. :::cplusplus - NSArray* models = [NSArray arrayWithObjects:customer, product, nil]; + NSMutableArray* models = [NSMutableArray arrayWithObjects:customer, product, nil]; Call the RhoConnectClient method addModels to add those models to your client. :::cplusplus [sclient addModels:models]; @@ -249,41 +249,60 @@ return (NSUInteger)[arItems count]; } ## RhoConnectClient Class API -The RhoConnectClient class contains properties and methods to build an Objective C RhoConnect client and connect it with a RhoConnect server. +The RhoConnectClient class contains the following properties and methods to build an Objective C RhoConnect client and connect it with a RhoConnect server. -## threaded\_mode (RhoConnectClient property) + * <a href="#threaded_mode">threaded_mode property</a> + * <a href="#poll_interval">poll_interval property</a> + * <a href="#sync_server">sync_server property</a> + * <a href="#initDatabase">initDatabase</a> + * <a href="#addModels">addModels</a> + * <a href="#database_full_reset_and_logout">database\_full\_reset\_and\_logout</a> + * <a href="#database_client_reset">database\_client\_reset</a> + * <a href="#initDatabase">initDatabase</a> + * <a href="#loginWithUser">loginWithUser</a> + * <a href="#loginWithUser (with callback)">loginWithUser (with callback)</a> + * <a href="#setNotification">setNotification</a> + * <a href="#clearNotification">clearNotification</a> + * <a href="#is_logged_in">is\_logged\_in</a> + * <a href="#syncAll">syncAll</a> + * <a href="#search">search</a> + * <a href="#setObjectNotification">setObjectNotification</a> + * <a href="#clearObjectNotification">clearObjectNotification</a> + * <a href="#addObjectNotify">addObjectNotify</a> +### <a id="threaded_mode"></a>threaded\_mode property + BOOL. Set to false to get the result of operations as a return value. (Set to true to get notifications - not supported yet.) Default = false. :::cplusplus @property(setter=setThreadedMode) BOOL threaded_mode; -## poll\_interval (RhoConnectClient property) +### <a id="poll_interval"></a>poll\_interval property int. Not yet supported. Default = 0. :::cplusplus @property(setter=setPollInterval) int poll_interval; -## sync\_server (RhoConnectClient property) +### <a id="sync_server"></a>sync\_server property NSString. Sets the RhoConnect server url, for example: "`http://<ip>:<port>/application`" :::cplusplus @property(assign, setter=setSyncServer) NSString* sync_server; -## initDatabase (RhoConnectClient method) +### <a id="initDatabase"></a>initDatabase Initializes your client database. Call this method before you create and use a client. ::::cplusplus + (void) initDatabase; -## addModels (RhoConnectClient method) +### <a id="addModels"></a>addModels Adds your model objects to your client database, allowing them to sync with the RhoConnect server. :::cplusplus - (void) addModels:(NSArray*)models; @@ -293,19 +312,26 @@ <td><code>models</code></td> <td>NSArray containing the model objects.</td> </tr> </table> -## database\_full\_reset\_and\_logout (RhoConnectClient method) +### <a id="database_full_reset_and_logout"></a>database\_full\_reset\_and\_logout Resets all data for all models in your local database, and then performs logout. :::cplusplus - (void) database_full_reset_and_logout; -## loginWithUser (RhoConnectClient method) +### <a id="database_client_reset"></a>database\_client\_reset +Resets all data for all models in your local database and delete client ID. Use this method for 'unknown client' error + + :::cplusplus + - (void) database_client_reset; + +### <a id="loginWithUser">loginWithUser + Returns a RhoConnectNotify object containing login data after logging your client database into the RhoConnect server. :::cplusplus - (RhoConnectNotify*) loginWithUser: (NSString*) user pwd:(NSString*) pwd; @@ -318,11 +344,11 @@ <td><code>pwd</code></td> <td>NSString containing the password.</td> </tr> </table> -## loginWithUser (RhoConnectClient method) +### <a id="loginWithUser (with callback)">loginWithUser (with callback) Logs your client database into the RhoConnect server and calls a selector callback target method when the login process is finished. :::cplusplus - (void) loginWithUser: (NSString*) user pwd:(NSString*) pwd callback:(SEL) callback target:(id)target; @@ -340,11 +366,11 @@ <td><code>callback:(SEL) callback target:(id)target</code></td> <td>The reference to the callback method. An example could be <code>callback:@selector(loginComplete:) target:self</code>. You would write the callback method loginComplete to perform actions when the login process completes.</td> </tr> </table> -## setNotification (RhoConnectClient method) +### <a id="setNotification">setNotification Set the sync notification callback method. :::cplusplus - (void) setNotification: (SEL) callback target:(id)target; @@ -354,32 +380,32 @@ <td><code>callback:(SEL) target:(id)target</code></td> <td>The reference to the callback method that performs actions upon a sync notification.</td> </tr> </table> -## clearNotification (RhoConnectClient method) +### <a id="clearNotification">clearNotification Instance method. Clear the sync notification callback. :::cplusplus - (void) clearNotification; -## is\_logged\_in (RhoConnectClient method) +### <a id="is_logged_in">is\_logged\_in Instance method. Returns true if your RhoConnect session is logged in (if the login session exists in the database), false otherwise. :::cplusplus - (BOOL) is_logged_in; -## syncAll (RhoConnectClient method) +### <a id="syncAll">syncAll Instance method. Returns a RhoConnectNotify object after running a sync on all the models for your RhoConnect client. :::cplusplus - (RhoConnectNotify*) syncAll; -## search (RhoConnectClient method) +### <a id="search">search Instance method. Returns a RhoConnectNotify object after sending a search request to the RhoConnect server. :::cplusplus - (RhoConnectNotify*) search: (NSArray*)models from: (NSString*) from params: (NSString*)params sync_changes: (BOOL) @@ -406,11 +432,11 @@ <td><code>progress_step</code></td> <td>(Optional) int. Define how often the search callback will be executed when the RhoConnectNotify status is "in_progress".</td> </tr> </table> -## setObjectNotification (RhoConnectClient method) +### <a id="setObjectNotification">setObjectNotification Instance method. Sets the callback method for object notification. The callback receives a RhoConnectObjectNotify object as a parameter. This RhoConnectObjectNotify object contains three arrays of hashes for the objects and their source ids that have been updated, created, and deleted, allowing you to display which records were changed. - (void) setObjectNotification: (SEL) callback target:(id)target; @@ -419,17 +445,17 @@ <td><code>(SEL) callback target:(id)target</code></td> <td>The name of your callback method.</td> </tr> </table> -## clearObjectNotification (RhoConnectClient method) +### <a id="clearObjectNotification"></a>clearObjectNotification - (void) clearObjectNotification; Instance method. Clears the callback method for object notification. -## addObjectNotify (RhoConnectClient method) +### <a id="addObjectNotify"></a>addObjectNotify Instance method. Add an object to track changes: create, update, delete. :::cplusplus - (void) addObjectNotify: (int) nSrcID szObject:(NSString*) szObject; @@ -452,34 +478,52 @@ ... [sclient addObjectNotify: [[item objectForKey:@"source_id"] intValue] szObject:[item valueForKey:@"object"] ]; ## RhomModel Class API -The RhomModel class contains properties and methods for setting and using RhomModel objects; those objects are RhoConnect models and their attributes. +The RhomModel class contains the following properties and methods for setting and using RhomModel objects; RhomModel objects are RhoConnect models and their attributes. -## name (RhomModel property) + * <a href="#name">name property</a> + * <a href="#sync_type">sync_type property</a> + * <a href="#model_type">model_type property</a> + * <a href="#associations">associations property</a> + * <a href="#init">init</a> + * <a href="#sync">sync</a> + * <a href="#sync (with callback)">sync (with callback)</a> + * <a href="#setNotification">setNotification</a> + * <a href="#clearNotification">clearNotification</a> + * <a href="#create">create</a> + * <a href="#find">find</a> + * <a href="#find_first">find_first</a> + * <a href="#find_all">find_all</a> + * <a href="#save">save</a> + * <a href="#destroy">destroy</a> + * <a href="#startBulkUpdate">startBulkUpdate</a> + * <a href="#stopBulkUpdate">stopBulkUpdate</a> +### <a id="name"></a>name property + NSString. Sets the model name. :::cplusplus @property(assign) NSString* name; -## sync\_type (RhomModel property) +### <a id="sync_type"></a>sync\_type property int. Sets the synchronization type: RST\_INCREMENTAL or RST\_BULK\_ONLY. :::cplusplus @property(assign) int sync_type; -## model\_type (RhomModel property) +### <a id="model_type">model\_type property int. Sets the model type: RMT\_PROPERTY\_BAG (default) or RMT\_PROPERTY\_FIXEDSCHEMA. :::cplusplus @property(assign) int model_type; -## associations (RhomModel property) +### <a id="associations">associations property The associations dictionary is a property of the model that controls its synchronization process. When one model (model A) has an association with another model (model B), this forces the other model (model B) synchronized along with the model (model A). :::cplusplus // Associations dictionary: the key is the model attribute name, @@ -493,25 +537,25 @@ :::cplusplus RhomModel* order = [[RhomModel alloc] init]; order.name = @"Order"; order.associations = [NSDictionary dictionaryWithObjectsAndKeys: @"Customer", @"customer", @"Product", @"product", nil]; -## init (RhomModel method) +### <a id="init">init Initializes a model object. :::cplusplus - (id) init; -## sync (RhomModel method) +### <a id="sync">sync Returns a RhoConnectNotify object containing sync information, after running a sync on this model. :::cplusplus - (RhoConnectNotify*) sync; -## sync with callback (RhomModel method) +### <a id="sync (with callback)">sync (with callback) Runs a sync on this model, and calls a callback, passing the callback the RhoConnectNotify status parameter for the synchronization: "in\_progress", "ok", "error", "complete". :::cplusplus - (void) sync: (SEL) callback target:(id)target; @@ -529,12 +573,34 @@ } return 1; } -## create (RhomModel method) +### <a id="setNotification">setNotification +Set the sync notification callback method for the Model. + + :::cplusplus + - (void) setNotification: (SEL) callback target:(id)target; + +<table border="1"> +<tr> + <td><code>callback:(SEL) target:(id)target</code></td> + <td>The reference to the callback method that performs actions upon a sync notification.</td> +</tr> +</table> + +### <a id="clearNotification">clearNotification + +Instance method. Clear the sync notification callback for the Model. + + :::cplusplus + - (void) clearNotification; + + +### <a id="create">create + Create a model object with attributes and save it to the database, the object id will be generated automatically if not set. :::cplusplus - (void) create: (NSMutableDictionary *) data; @@ -543,11 +609,11 @@ <td><code>data</code></td> <td>NSMutableDictionary. The object containing the attribute data for this model.</td> </tr> </table> -## find (RhomModel method) +### <a id="find">find Returns an NSMutableDictionary object containing a model with the given object id. :::cplusplus - (NSMutableDictionary *) find: (NSString*)object_id; @@ -557,11 +623,11 @@ <td><code>object_id</code></td> <td>NSString. The object id.</td> </tr> </table> -## find\_first (RhomModel method) +### <a id="find_first">find\_first Returns an NSMutableDictionary object containing the first model object found with the given set of model attributes. :::cplusplus - (NSMutableDictionary *) find_first: (NSDictionary *)cond; @@ -582,11 +648,11 @@ [cond release]; if ( !prod ) { // not found } -## find\_all (RhomModel method) +### <a id="find_all">find\_all Returns a NSMutableArray containing all the model objects that match the given set of attributes. :::cplusplus - (NSMutableArray *) find_all: (NSDictionary *)cond; @@ -596,11 +662,11 @@ <td><code>cond</code></td> <td>A NSDictionary object containing the model attributes to find.</td> </tr> </table> -## save (RhomModel method) +### <a id="save">save Saves a model object with the given data to the database. :::cplusplus - (void) save: (NSDictionary *)data; @@ -610,11 +676,11 @@ <td><code>data</code></td> <td>A NSDictionary object containing the attribute data for the model object that is saved.</td> </tr> </table> -## destroy (RhomModel method) +### <a id="destroy">destroy Delete model objects from the database that contain the given data. :::cplusplus - (void) destroy: (NSDictionary *)data; @@ -624,18 +690,18 @@ <td><code>data</code></td> <td>A NSDictionary object containing the attribute data for the model objects that are to be deleted.</td> </tr> </table> -## startBulkUpdate (RhomModel method) +### <a id="startBulkUpdate">startBulkUpdate Run this method when you start to create or update a bunch of models; it will optimize database access. Equal to start transaction. :::cplusplus - (void) startBulkUpdate; -## stopBulkUpdate (RhomModel method) +### <a id="stopBulkUpdate">stopBulkUpdate Run this method when you start to create or update a bunch of models; it will optimize database access. Equal to commit transaction. :::cplusplus - (void) stopBulkUpdate; @@ -729,8 +795,8 @@ This will produce a zipfile in the folder called `rhoconnect-client-<someversion>.zip` where `<someversion>` is the version of the client. ## Release procedure 1. Unzip package to some folder -2. Open project `rhoconnect-client\ObjectiveC\Tests\RhoConnectClientTest` in xcode and run. See log - SUCCESS should be at the end of log +2. Open project `rhoconnect-client\ObjectiveC\Tests\RhoConnectClientTest` in xcode and run. See log - SUCCESS should be at the end of log. -3. Open project `rhoconnect-client\Samples\ObjectiveC\store` in xcode and run. Press Login, you should see several items, click on item, you should see details +3. Open project `rhoconnect-client\Samples\ObjectiveC\store` in xcode and run. Press Login, you should see several items, click on item, you should see details.