Creating, Updating, or Deleting Records

In SDK version 2.1 ESD #2 applications, after creating, updating or deleting records, you called the save method to save the change to the local database, and called submitPending to send the change to the server. In SDK version 2.1 ESD #3 applications, after updating or creating records, you call the save and submitPending methods, and call synchronize to send the changes to the server.

  1. In the 2.1 ESD #2 Tutorial: iOS Object API Application Development, locate this code:
    [newCustomer save];
    [newCustomer submitPending];
    Note: In MBS, the generated operation from submitPending is automatically sent to the Unwired Server. In your RBS applications, you must instead invoke the synchronize method to send the record to the Unwired Server.
  2. Add the following new code. You call synchronize to send the update or new record to the server. The call can be either synchronous or asynchronous.
    @try {
      [SUP101SUP101DB synchronize];
    }
    @catch (NSException *exception) {
      MBOLogError(@"%@: %@", [exception name], [exception reason]);
    } 

    The above code examples synchronize the default group. Alternatively, you can synchronize based on the synchronization group the MBO belongs to.

    NSString *customer_sg = [customer metaData].synchronizationGroup;  
    [db synchronize:customer_sg]; 
    Note: Unlike MBS, the submitPending method in RBS is a client-side only operation, but is still required before calling the database class’s synchronize method, which sends the changes to the server.