rhoconnect 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,736 @@
1
+ Using RhoConnect without Rhodes: Objective C Client API
2
+ ===
3
+
4
+ The RhoConnect Client is a library that adds sync data capability to your non-Rhodes applications, such as applications created in XCode or Android Java. Using this library, you can enable synchronized data between your Objective C iOS device application and a RhoConnect server.
5
+
6
+ Source Code
7
+ -----------
8
+ The source code for the RhoConnect client store example is located here.
9
+
10
+ * [rhoconnect-client\Samples\ObjectiveC\store](http://github.com/rhomobile/rhodes/tree/master/rhoconnect-client/Samples/ObjectiveC/store/)
11
+
12
+ Pre-requisite Reading
13
+ ---------------------
14
+ * [iOS development](http://developer.apple.com/devcenter/ios/index.action)
15
+
16
+ ## Features supported
17
+
18
+ <table>
19
+ <tr><th>Feature</th><th>&nbsp;Ruby&nbsp;</th><th>ObjectiveC</th></tr>
20
+ <tr><td>Property bag model</td><td>yes</td><td>yes</td></tr>
21
+ <tr><td>Fixed schema mode</td><td>yes</td><td>yes</td></tr>
22
+ <tr><td>Model associations</td><td>yes</td><td>yes</td></tr>
23
+ <tr><td>BLOB attributes</td><td>yes</td><td>yes</td></tr>
24
+ <tr><td>Bulk sync</td><td>yes</td><td>yes</td></tr>
25
+ <tr><td>Sync</td><td>yes</td><td>yes</td></tr>
26
+ <tr><td>Notifications</td><td>yes</td><td>yes</td></tr>
27
+ <tr><td>Database reset</td><td>yes</td><td>yes</td></tr>
28
+ <tr><td>Authentication</td><td>yes</td><td>yes</td></tr>
29
+ <tr><td>DB partitioning</td><td>yes</td><td>not yet</td></tr>
30
+ </table>
31
+
32
+ ## Setup
33
+
34
+ The RhoConnect Client is part of the Rhodes repository; it contains files that you will need to add to your Xcode project. You can get the client [on github](https://github.com/rhomobile/rhodes/downloads). (Select the latest 'rhoconnect-client' package).
35
+
36
+ Create a new Xcode project or open an existing one in Xcode.
37
+
38
+ ### Adding RhoConnectClient to your Xcode Project
39
+
40
+ Do the following steps to add `<rhoconnect-client>/objectivec/RhoConnectClient.xcodeproj` as a dependency so that the RhoConnectClient library will link with your project.
41
+
42
+ 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.
43
+
44
+ <img src="rhoconnect-objc-client-tutorial/rhoconnectclient-groupfile.png" alt="RhoConnectClient in Groups & Files" />
45
+
46
+ 2. Under Groups and Files, open the Targets icon.
47
+ 3. Right-click on your project-named target.
48
+ 4. Choose Get Info, then click on the General tab.
49
+ 5. In Direct Dependencies, click the + button.
50
+ 6. Choose the dependency from RhoConnectClient.xcodeproj.
51
+
52
+ <img src="rhoconnect-objc-client-tutorial/direct-dependency.png" alt="RhoConnectClient Direct Dependency" />
53
+
54
+ ### Adding Xcode Libraries
55
+
56
+ Do the following steps to add libraries:
57
+
58
+ 1. Under Groups & Files, right-click on your project (the name at the top of the list).
59
+ 2. Select Add->Existing Frameworks from the popup menu.
60
+ 3. Add the following to your project: `libstdc++6.dylib, libsqlite3.dylib, libz.dylib, CFNetwork.framework`.
61
+
62
+ <img src="rhoconnect-objc-client-tutorial/add-frameworks.png" alt="Add Frameworks" />
63
+
64
+ ### Adding Schema Files
65
+
66
+ Do the following steps to add schema files to your Copy Bundle Resources build phase:
67
+ 1. Copy the folder `<rhodes>/platform/shared/db/res/db` into your Xcode project folder.
68
+ 2. Drag the copied db folder into your Xcode project, onto the project-named icon under Groups & Files. The db folder should now appear in the Groups & Files list.
69
+ 3. Under Groups and Files, open the Targets icon, then open the project-named icon under Targets, then open the Copy Bundle Resources folder. You should see sync.schema listed there.
70
+ 4. Open and edit the sync.schema file. Add a create table statement for every model you will use in your project. For example, for a model named product:
71
+
72
+ :::term
73
+ CREATE TABLE product (
74
+ "client_id" VARCHAR(255) default NULL);
75
+
76
+ ## Coding a RhoConnect Client
77
+
78
+ This section discusses the general steps you perform to code a RhoConnect client in Objective C, using the store example. It is not a tutorial for coding a complete Xcode application, but instead discusses the RhoConnect code that you need to create.
79
+
80
+ ### Initialize the Database
81
+
82
+ Call the RhoConnectClient method initDatabase to initialize the local database for the models. You must do this before you initialize and use a RhoConnectClient object.
83
+
84
+ :::cplusplus
85
+ [RhoConnectClient initDatabase];
86
+
87
+ ### Initialize the Client
88
+
89
+ Call the RhomModel init method for each model. In the Store example, initialize a customer model and a product model.
90
+
91
+ :::cplusplus
92
+ customer = [[RhomModel alloc] init];
93
+ customer.name = @"Customer";
94
+ product = [[RhomModel alloc] init];
95
+ product.name = @"Product";
96
+
97
+ Call init for RhoConnectClient to initialize your client.
98
+
99
+ :::cplusplus
100
+ sclient = [[RhoConnectClient alloc] init];
101
+
102
+ Set up an NSArray containing the models for your client.
103
+
104
+ :::cplusplus
105
+ NSArray* models = [NSArray arrayWithObjects:customer, product, nil];
106
+
107
+ Call the RhoConnectClient method addModels to add those models to your client.
108
+
109
+ :::cplusplus
110
+ [sclient addModels:models];
111
+
112
+ Set the RhoConnectClient property sync\_server to the URL of the RhoConnect server for your client.
113
+
114
+ :::cplusplus
115
+ sclient.sync_server = @"http://rhodes-store-server.heroku.com/application";
116
+
117
+ Here is the Store code for the initialization process, contained in RhoConnectEngine.m.
118
+
119
+ :::cplusplus
120
+ - (id)init
121
+ {
122
+ if ( sharedInst != nil ) {
123
+ [NSException raise:NSInternalInconsistencyException
124
+ format:@"[%@ %@] cannot be called; use +[%@ %@] instead",
125
+ NSStringFromClass([self class]), NSStringFromSelector(_cmd),
126
+ NSStringFromClass([self class]),
127
+ NSStringFromSelector(@selector(sharedInstance))];
128
+
129
+ } else if ( self = [super init] ) {
130
+ sharedInst = self;
131
+
132
+ [RhoConnectClient initDatabase];
133
+
134
+ customer = [[RhomModel alloc] init];
135
+ customer.name = @"Customer";
136
+
137
+ product = [[RhomModel alloc] init];
138
+ product.name = @"Product";
139
+
140
+ sclient = [[RhoConnectClient alloc] init];
141
+ NSArray* models = [NSArray arrayWithObjects:customer, product, nil];
142
+
143
+ [sclient addModels:models];
144
+
145
+ sclient.sync_server = @"http://rhodes-store-server.heroku.com/application";
146
+ sclient.threaded_mode = TRUE;
147
+
148
+ loginState = [sclient is_logged_in] ? logged_in : logged_out;
149
+ }
150
+ return sharedInst;
151
+ }
152
+
153
+ ### Log Into the RhoConnect Server
154
+
155
+ Call the RhoConnectClient loginWithUser method to log into the RhoConnect server.
156
+
157
+ :::cplusplus
158
+ [ [RhoConnectEngine sharedInstance].syncClient loginWithUser:txtLogin.text pwd:txtPassword.text callback:@selector(loginComplete:) target:self];
159
+
160
+ Here is the Store code for the login process, contained in LoginViewController.m. It contains both a login method that calls loginWithUser, and a callback method called by loginWithUser, that checks to see if the login is active.
161
+
162
+ :::cplusplus
163
+ - (void)loginComplete:(RhoConnectNotify*) notify
164
+ {
165
+ if ( notify.error_code != RHO_ERR_NONE || ![[RhoConnectEngine sharedInstance].syncClient is_logged_in])
166
+ [RhoConnectEngine sharedInstance].loginState = failed;
167
+ else
168
+ [RhoConnectEngine sharedInstance].loginState = logged_in;
169
+
170
+ [waitPage loginComplete: [notify error_message] ];
171
+
172
+ [notify release];
173
+ }
174
+
175
+ - (IBAction)doLogin:(id)sender
176
+ {
177
+ [RhoConnectEngine sharedInstance].loginState = in_progress;
178
+ [[self navigationController] pushViewController:waitPage animated:YES];
179
+
180
+ [ [RhoConnectEngine sharedInstance].syncClient loginWithUser:txtLogin.text pwd:txtPassword.text callback:@selector(loginComplete:) target:self];
181
+ }
182
+
183
+ ### Synchronize Data
184
+
185
+ Call the RhoConnectClient setNotification method to call a callback method that notifies about the state of the synchronization.
186
+
187
+ :::cplusplus
188
+ [ [RhoConnectEngine sharedInstance].syncClient setNotification: @selector(syncAllComplete:) target:self];
189
+
190
+ Call a sync method, such as the RhoConnectClient syncAll method or the RhomModel sync method, to sync your client model data with the RhoConnect server.
191
+
192
+ :::cplusplus
193
+ [ [RhoConnectEngine sharedInstance].syncClient syncAll];
194
+
195
+ Call clearNotification upon completion of the sync.
196
+
197
+ :::cplusplus
198
+ [ [RhoConnectEngine sharedInstance].syncClient clearNotification];
199
+
200
+ Here is the Store code for the sync process, contained in WaitLoginController.m. It contains both a loginComplete method (called from the loginWithUser callback method) that calls setNotification and syncAll, and the setNotification callback method that calls clearNotification when the sync is complete.
201
+
202
+ :::cplusplus
203
+ - (void)syncAllComplete:(RhoConnectNotify*) notify
204
+ {
205
+ if ( [notify.status compare:@"in_progress"] == 0)
206
+ {
207
+ }else if ([notify.status compare:@"complete"] == 0)
208
+ {
209
+ [[self navigationController] pushViewController:homePage animated:YES];
210
+ [ [RhoConnectEngine sharedInstance].syncClient clearNotification];
211
+ }else if ([notify.status compare:@"error"] == 0)
212
+ {
213
+ }
214
+ }
215
+
216
+ - (void)loginComplete:(NSString*) errorMessage
217
+ {
218
+ NSLog(@"Login error message: \"%@\"", errorMessage);
219
+ [indicator stopAnimating];
220
+ if ([RhoConnectEngine sharedInstance].loginState == logged_in)
221
+ {
222
+ [ [RhoConnectEngine sharedInstance].syncClient setNotification: @selector(syncAllComplete:) target:self];
223
+ [ [RhoConnectEngine sharedInstance].syncClient syncAll];
224
+ } else {
225
+ lblMessage.text = errorMessage;
226
+ self.navigationItem.hidesBackButton = false;
227
+ }
228
+ }
229
+
230
+ ### Search the Client Database for Models
231
+
232
+ Call a RhomModel find method (find, find\_first, find\_all) to find model objects in the client database. This code sample for the find\_all method fetches all the models in the database; you can also search for models containing certain attribute data.
233
+
234
+ :::cplusplus
235
+ NSMutableArray* arItems = [[RhoConnectEngine sharedInstance].product find_all:nil];
236
+ NSDictionary* item = [arItems objectAtIndex: 0 ];
237
+ textBrand = [item valueForKey:@"brand"];
238
+
239
+ Here is the Store code for the find process, contained in RootViewController.m. It contains a call to the find\_all method, and returns the total count of the models in the database.
240
+
241
+ :::cplusplus
242
+ // Customize the number of rows in the table view.
243
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
244
+ {
245
+ if (!arItems)
246
+ arItems = [[RhoConnectEngine sharedInstance].product find_all:nil];
247
+
248
+ //warning here because this may be dictionary or an array when called.
249
+ return (NSUInteger)[arItems count];
250
+ }
251
+
252
+ ## RhoConnectClient Class API
253
+
254
+ The RhoConnectClient class contains properties and methods to build an Objective C RhoConnect client and connect it with a RhoConnect server.
255
+
256
+ ## threaded\_mode (RhoConnectClient property)
257
+
258
+ 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.
259
+
260
+ :::cplusplus
261
+ @property(setter=setThreadedMode) BOOL threaded_mode;
262
+
263
+ ## poll\_interval (RhoConnectClient property)
264
+
265
+ int. Not yet supported. Default = 0.
266
+
267
+ :::cplusplus
268
+ @property(setter=setPollInterval) int poll_interval;
269
+
270
+ ## sync\_server (RhoConnectClient property)
271
+
272
+ NSString. Sets the RhoConnect server url, for example: "`http://<ip>:<port>/application`"
273
+
274
+ :::cplusplus
275
+ @property(assign, setter=setSyncServer) NSString* sync_server;
276
+
277
+ ## initDatabase (RhoConnectClient method)
278
+
279
+ Initializes your client database. Call this method before you create and use a client.
280
+
281
+ ::::cplusplus
282
+ + (void) initDatabase;
283
+
284
+ ## addModels (RhoConnectClient method)
285
+
286
+ Adds your model objects to your client database, allowing them to sync with the RhoConnect server.
287
+
288
+ :::cplusplus
289
+ - (void) addModels:(NSArray*)models;
290
+
291
+ <table border="1">
292
+ <tr>
293
+ <td><code>models</code></td>
294
+ <td>NSArray containing the model objects.</td>
295
+ </tr>
296
+ </table>
297
+
298
+ ## database\_full\_reset\_and\_logout (RhoConnectClient method)
299
+
300
+ Resets all data for all models in your local database, and then performs logout.
301
+
302
+ :::cplusplus
303
+ - (void) database_full_reset_and_logout;
304
+
305
+ ## loginWithUser (RhoConnectClient method)
306
+
307
+ Returns a RhoConnectNotify object containing login data after logging your client database into the RhoConnect server.
308
+
309
+ :::cplusplus
310
+ - (RhoConnectNotify*) loginWithUser: (NSString*) user pwd:(NSString*) pwd;
311
+
312
+ <table border="1">
313
+ <tr>
314
+ <td><code>usr</code></td>
315
+ <td>NSString containing the user name.</td>
316
+ </tr>
317
+ <tr>
318
+ <td><code>pwd</code></td>
319
+ <td>NSString containing the password.</td>
320
+ </tr>
321
+ </table>
322
+
323
+ ## loginWithUser (RhoConnectClient method)
324
+
325
+ Logs your client database into the RhoConnect server and calls a selector callback target method when the login process is finished.
326
+
327
+ :::cplusplus
328
+ - (void) loginWithUser: (NSString*) user pwd:(NSString*) pwd callback:(SEL) callback target:(id)target;
329
+
330
+ <table border="1">
331
+ <tr>
332
+ <td><code>usr</code></td>
333
+ <td>NSString containing the user name.</td>
334
+ </tr>
335
+ <tr>
336
+ <td><code>pwd</code></td>
337
+ <td>NSString containing the password.</td>
338
+ </tr>
339
+ <tr>
340
+ <td><code>callback:(SEL) callback target:(id)target</code></td>
341
+ <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>
342
+ </tr>
343
+ </table>
344
+
345
+ ## setNotification (RhoConnectClient method)
346
+
347
+ Set the sync notification callback method.
348
+
349
+ :::cplusplus
350
+ - (void) setNotification: (SEL) callback target:(id)target;
351
+
352
+ <table border="1">
353
+ <tr>
354
+ <td><code>callback:(SEL) target:(id)target</code></td>
355
+ <td>The reference to the callback method that performs actions upon a sync notification.</td>
356
+ </tr>
357
+ </table>
358
+
359
+ ## clearNotification (RhoConnectClient method)
360
+
361
+ Instance method. Clear the sync notification callback.
362
+
363
+ :::cplusplus
364
+ - (void) clearNotification;
365
+
366
+ ## is\_logged\_in (RhoConnectClient method)
367
+
368
+ Instance method. Returns true if your RhoConnect session is logged in (if the login session exists in the database), false otherwise.
369
+
370
+ :::cplusplus
371
+ - (BOOL) is_logged_in;
372
+
373
+ ## syncAll (RhoConnectClient method)
374
+
375
+ Instance method. Returns a RhoConnectNotify object after running a sync on all the models for your RhoConnect client.
376
+
377
+ :::cplusplus
378
+ - (RhoConnectNotify*) syncAll;
379
+
380
+ ## search (RhoConnectClient method)
381
+
382
+ Instance method. Returns a RhoConnectNotify object after sending a search request to the RhoConnect server.
383
+
384
+ :::cplusplus
385
+ - (RhoConnectNotify*) search: (NSArray*)models from: (NSString*) from params: (NSString*)params sync_changes: (BOOL)
386
+ sync_changes progress_step: (int) progress_step;
387
+
388
+ <table border="1">
389
+ <tr>
390
+ <td><code>models</code></td>
391
+ <td>NSArray containing the names of the model names to search in.</td>
392
+ </tr>
393
+ <tr>
394
+ <td><code>from</code></td>
395
+ <td>(Optional) NSString. Sets the RhoConnect path that the records are fetched with. Default = "search".</td>
396
+ </tr>
397
+ <tr>
398
+ <td><code>params</code></td>
399
+ <td>NSString. A string containing the name/value search items, in the form "param1=val1&param2=val2&param3=val3". The values must be url-encoded.</td>
400
+ </tr>
401
+ <tr>
402
+ <td><code>sync_changes</code></td>
403
+ <td>BOOL. TRUE if data with local changes is pushed to the server before the search is performed, FALSE otherwise.</td>
404
+ </tr>
405
+ <tr>
406
+ <td><code>progress_step</code></td>
407
+ <td>(Optional) int. Define how often the search callback will be executed when the RhoConnectNotify status is "in_progress".</td>
408
+ </tr>
409
+ </table>
410
+
411
+ ## setObjectNotification (RhoConnectClient method)
412
+
413
+ 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.
414
+
415
+ - (void) setObjectNotification: (SEL) callback target:(id)target;
416
+
417
+ <table border="1">
418
+ <tr>
419
+ <td><code>(SEL) callback target:(id)target</code></td>
420
+ <td>The name of your callback method.</td>
421
+ </tr>
422
+ </table>
423
+
424
+ ## clearObjectNotification (RhoConnectClient method)
425
+
426
+ - (void) clearObjectNotification;
427
+
428
+ Instance method. Clears the callback method for object notification.
429
+
430
+ ## addObjectNotify (RhoConnectClient method)
431
+
432
+ Instance method. Add an object to track changes: create, update, delete.
433
+
434
+ :::cplusplus
435
+ - (void) addObjectNotify: (int) nSrcID szObject:(NSString*) szObject;
436
+
437
+ <table border="1">
438
+ <tr>
439
+ <td><code>nSrcID</code></td>
440
+ <td>int. The object ID of the source on the server with which this RHoConnectClient syncs. You can provide this with the "source\_id" property value.</td>
441
+ </tr>
442
+ <tr>
443
+ <td><code>szObject</code></td>
444
+ <td>NSString. The object ID of the item created to track the changes to this RhoConnectClient.</td>
445
+ </tr>
446
+ </table>
447
+
448
+ Sample call:
449
+
450
+ :::cplusplus
451
+ RhoConnectClient* sclient;
452
+ ...
453
+ [sclient addObjectNotify: [[item objectForKey:@"source_id"] intValue] szObject:[item valueForKey:@"object"] ];
454
+
455
+ ## RhomModel Class API
456
+
457
+ The RhomModel class contains properties and methods for setting and using RhomModel objects; those objects are RhoConnect models and their attributes.
458
+
459
+ ## name (RhomModel property)
460
+
461
+ NSString. Sets the model name.
462
+
463
+ :::cplusplus
464
+ @property(assign) NSString* name;
465
+
466
+ ## sync\_type (RhomModel property)
467
+
468
+ int. Sets the synchronization type: RST\_INCREMENTAL or RST\_BULK\_ONLY.
469
+
470
+ :::cplusplus
471
+ @property(assign) int sync_type;
472
+
473
+ ## model\_type (RhomModel property)
474
+
475
+ int. Sets the model type: RMT\_PROPERTY\_BAG (default) or RMT\_PROPERTY\_FIXEDSCHEMA.
476
+
477
+ :::cplusplus
478
+ @property(assign) int model_type;
479
+
480
+ ## associations (RhomModel property)
481
+
482
+ 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).
483
+
484
+ :::cplusplus
485
+ // Associations dictionary: the key is the model attribute name,
486
+ // the value is the associated model name.
487
+ // While using associations, use the object_id attribute as object reference
488
+
489
+ @property(assign) NSDictionary* associations;
490
+
491
+ Example of associating two models, customer and product:
492
+
493
+ :::cplusplus
494
+ RhomModel* order = [[RhomModel alloc] init];
495
+ order.name = @"Order";
496
+ order.associations = [NSDictionary dictionaryWithObjectsAndKeys: @"Customer", @"customer", @"Product", @"product", nil];
497
+
498
+ ## init (RhomModel method)
499
+
500
+ Initializes a model object.
501
+
502
+ :::cplusplus
503
+ - (id) init;
504
+
505
+ ## sync (RhomModel method)
506
+
507
+ Returns a RhoConnectNotify object containing sync information, after running a sync on this model.
508
+
509
+ :::cplusplus
510
+ - (RhoConnectNotify*) sync;
511
+
512
+ ## sync with callback (RhomModel method)
513
+
514
+ 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".
515
+
516
+ :::cplusplus
517
+ - (void) sync: (SEL) callback target:(id)target;
518
+
519
+ Example:
520
+
521
+ :::cplusplus
522
+ int shouldSyncProductByName()
523
+ {
524
+ RhoConnectNotify* res = [[product sync] retain];
525
+ int nErr = res.error_code;
526
+ [res release];
527
+ if ( nErr!= RHO_ERR_NONE ) {
528
+ return 0;
529
+ }
530
+
531
+ return 1;
532
+ }
533
+
534
+ ## create (RhomModel method)
535
+
536
+ Create a model object with attributes and save it to the database, the object id will be generated automatically if not set.
537
+
538
+ :::cplusplus
539
+ - (void) create: (NSMutableDictionary *) data;
540
+
541
+ <table border="1">
542
+ <tr>
543
+ <td><code>data</code></td>
544
+ <td>NSMutableDictionary. The object containing the attribute data for this model.</td>
545
+ </tr>
546
+ </table>
547
+
548
+ ## find (RhomModel method)
549
+
550
+ Returns an NSMutableDictionary object containing a model with the given object id.
551
+
552
+ :::cplusplus
553
+ - (NSMutableDictionary *) find: (NSString*)object_id;
554
+
555
+ <table border="1">
556
+ <tr>
557
+ <td><code>object_id</code></td>
558
+ <td>NSString. The object id.</td>
559
+ </tr>
560
+ </table>
561
+
562
+ ## find\_first (RhomModel method)
563
+
564
+ Returns an NSMutableDictionary object containing the first model object found with the given set of model attributes.
565
+
566
+ :::cplusplus
567
+ - (NSMutableDictionary *) find_first: (NSDictionary *)cond;
568
+
569
+ <table border="1">
570
+ <tr>
571
+ <td><code>cond</code></td>
572
+ <td>A NSDictionary object containing the model attributes to find.</td>
573
+ </tr>
574
+ </table>
575
+
576
+ Example call:
577
+
578
+ :::cplusplus
579
+ NSMutableDictionary* cond = [[NSMutableDictionary alloc] init];
580
+ [cond setValue: @"SomeRealName" forKey:@"name"];
581
+ prod = [[product find_first: cond] retain];
582
+ [cond release];
583
+ if ( !prod ) {
584
+ // not found
585
+ }
586
+
587
+ ## find\_all (RhomModel method)
588
+
589
+ Returns a NSMutableArray containing all the model objects that match the given set of attributes.
590
+
591
+ :::cplusplus
592
+ - (NSMutableArray *) find_all: (NSDictionary *)cond;
593
+
594
+ <table border="1">
595
+ <tr>
596
+ <td><code>cond</code></td>
597
+ <td>A NSDictionary object containing the model attributes to find.</td>
598
+ </tr>
599
+ </table>
600
+
601
+ ## save (RhomModel method)
602
+
603
+ Saves a model object with the given data to the database.
604
+
605
+ :::cplusplus
606
+ - (void) save: (NSDictionary *)data;
607
+
608
+ <table border="1">
609
+ <tr>
610
+ <td><code>data</code></td>
611
+ <td>A NSDictionary object containing the attribute data for the model object that is saved.</td>
612
+ </tr>
613
+ </table>
614
+
615
+ ## destroy (RhomModel method)
616
+
617
+ Delete model objects from the database that contain the given data.
618
+
619
+ :::cplusplus
620
+ - (void) destroy: (NSDictionary *)data;
621
+
622
+ <table border="1">
623
+ <tr>
624
+ <td><code>data</code></td>
625
+ <td>A NSDictionary object containing the attribute data for the model objects that are to be deleted.</td>
626
+ </tr>
627
+ </table>
628
+
629
+ ## startBulkUpdate (RhomModel method)
630
+
631
+ Run this method when you start to create or update a bunch of models; it will optimize database access. Equal to start transaction.
632
+
633
+ :::cplusplus
634
+ - (void) startBulkUpdate;
635
+
636
+ ## stopBulkUpdate (RhomModel method)
637
+
638
+ Run this method when you start to create or update a bunch of models; it will optimize database access. Equal to commit transaction.
639
+
640
+ :::cplusplus
641
+ - (void) stopBulkUpdate;
642
+
643
+ ## RhoConnectNotify Class API
644
+
645
+ Several RhoConnectClient methods return a RhoConnectNotify object. The properties for the RhoConnectNotify class provide access to sync notification objects as described [here](/rhodes/synchronization#notifications). (Developers do not set RhoConnectNotify properties, but only read them after a call to a RhoConnectClient method that returns a RhoConnectNotify object.)
646
+
647
+ <table border="1">
648
+ <tr>
649
+ <td><code>total_count</code></td>
650
+ <td>@property int. Total number of records that exist for this RhoConnect source.</td>
651
+ </tr>
652
+ <tr>
653
+ <td><code>processed_count</code></td>
654
+ <td>@property int. Number of records included in this sync page for an in\_progress (status = incremental) sync.</td>
655
+ </tr>
656
+ <tr>
657
+ <td><code>cumulative_count</code></td>
658
+ <td>@property int. Number of records the SyncEngine has processed so far for this source.</td>
659
+ </tr>
660
+ <tr>
661
+ <td><code>source_id</code></td>
662
+ <td>@property int. The id of the current model that is synchronizing.</td>
663
+ </tr>
664
+ <tr>
665
+ <td><code>error_code</code></td>
666
+ <td>@property int. The HTTP response code of the RhoConnect server error: 401, 500, 404, etc.</td>
667
+ </tr>
668
+ <tr>
669
+ <td><code>source_name</code></td>
670
+ <td>@property(assign) NSString*. Name of the model (i.e. "Product").</td>
671
+ </tr>
672
+ <tr>
673
+ <td><code>status</code></td>
674
+ <td>@property(assign) NSString*. Status of the current sync process: "in\_progress", "error", "ok", "complete", "schema-changed".</td>
675
+ </tr>
676
+ <tr>
677
+ <td><code>sync_type</code></td>
678
+ <td>@property(assign) NSString*. Type of sync used for this model: "incremental" or "bulk".</td>
679
+ </tr>
680
+ <tr>
681
+ <td><code>error_message</code></td>
682
+ <td>@property(assign) NSString*. Response body of error message (if any).</td>
683
+ </tr>
684
+ <tr>
685
+ <td><code>callback_params</code></td>
686
+ <td>@property(assign) NSString*. Callback parameters.</td>
687
+ </tr>
688
+ </table>
689
+
690
+ ## RhoConnectObjectNotify Class API
691
+
692
+ This class provides access to the sync object notification as described [here](/rhodes/synchronization#notifications).
693
+
694
+ The RhoConnectObjectNotify object contains three arrays of hashes for the objects and their source ids that have been updated, created, and deleted. Each hash contains values for the keys “object” and “source\_id” so you can display which records were changed.
695
+
696
+ <table border="1">
697
+ <tr>
698
+ <td><code>deleted_objects</code></td>
699
+ <td>@property(readonly) NSMutableArray*. An array containing the deleted objects.</td>
700
+ </tr>
701
+ <tr>
702
+ <td><code>updated_objects</code></td>
703
+ <td>@property(readonly) NSMutableArray*. An array containing the updated objects.</td>
704
+ </tr>
705
+ <tr>
706
+ <td><code>created_objects</code></td>
707
+ <td>@property(readonly) NSMutableArray*. An array containing the created objects.</td>
708
+ </tr>
709
+ <tr>
710
+ <td><code>deleted_source_ids</code></td>
711
+ <td>@property(readonly) NSMutableArray*. An array containing the deleted source ids.</td>
712
+ </tr>
713
+ <tr>
714
+ <td><code>updated_source_ids</code></td>
715
+ <td>@property(readonly) NSMutableArray*. An array containing the updated source ids.</td>
716
+ </tr>
717
+ <tr>
718
+ <td><code>created_source_ids</code></td>
719
+ <td>@property(readonly) NSMutableArray*. An array containing the created source ids.</td>
720
+ </tr>
721
+ </table>
722
+
723
+ ## Packaging RhoConnect Client
724
+ To package the RhoConnect Client archive for distribution, go to the top of the rhodes repository and run:
725
+
726
+ :::term
727
+ $ rake build:rhoconnect_client
728
+
729
+ This will produce a zipfile in the folder called `rhoconnect-client-<someversion>.zip` where `<someversion>` is the version of the client.
730
+
731
+ ## Release procedure
732
+ 1. Unzip package to some folder
733
+
734
+ 2. Open project `rhoconnect-client\ObjectiveC\Tests\RhoConnectClientTest` in xcode and run. See log - SUCCESS should be at the end of log
735
+
736
+ 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