Create Operation

The create operation allows the client to create a new record in the local database. To propagate the changes to the server, call submitPending.

(void)create

Example 1: Supports create operations on parent entities. The sequence of calls is:

SampleApp_Customer *newcustomer = [[SampleApp_Customer alloc] init];
newcustomer.fname = @”John”;
...  //Set the required fields for the customer
[newcustomer create];
[newcustomer submitPending];
while ([SampleApp_SampleAppDB hasPendingOperations])
		[NSThread sleepForTimeInterval:0.2];

Example 2: Supports create operations on child entities.

SampleApp_sales_order *order = [[SampleApp_sales_order alloc] init];
order.region = @"Eastern";
...  //Set the other required fields for the order

SampleApp_Customer *customer = [SampleApp_Customer find:1008];
[order setCustomer:customer];
[order create];
[order.customer refresh]; //refresh the parent
[order.customer submitPending];  //call submitPending on the parent.
while ([SampleApp_SampleAppDB hasPendingOperations])
		[NSThread sleepForTimeInterval:0.2];