Skip to end of metadata
Go to start of metadata

iOS SDK Content Creation and Updates - CM

 

- (void)saveRecord:(PWCMERecord *)record
 completionHandler:(void (^)(PWCMERecord *record, NSError *error))completionHandler;

This method creates a new record or updates an existing record if an ID of record is specified.

This method saves the record with a default priority, which may cause the task to execute after higher-priority tasks. To save records more urgently, create a PWCMEModifyRecordsOperation object with the desired priority. You can also use that operation object to save multiple records simultaneously.

Parameters

record – The record to save. You can create a new record or update an existing one if you specify its ID. An exception is thrown if this parameter is nil.

completionHandler – The block to execute with the results. Your block must be capable of running on any thread of the app and must take the following parameters: - record: The record object you attempted to save. - error: An error object or nil if the record was saved successfully. Use the information in the error object to determine whether a problem has a workaround.

Sample Code

PWCMERecordID *recordID = [[PWCMERecordID alloc] initWithStructureID:xxx parentIdentifier:nil];
PWCMERecord *record = [[PWCMERecord alloc] initWithRecordID:recordID];
record[@"firstName"] = @"John";
record[@"lastName"] = @"Smith";
record[@"title"] = @"President";
record[@"office"] = @"San Diego";
[[PWCMEContainer defaultContainer] saveRecord:record
                            completionHandler:^(PWCMERecord *record, NSError *error) {
    if (!error) {
        // The record was successfully created.
    }
    else {
        // Something went wrong. Be sure to handle the error!
        NSLog(@"Error: %@", error.debugDescription);
    }
}]; 

ON THIS PAGE

  • No labels