When pulling records from the sync engine, the client can change the format of property values without the sync engine interpreting the reformatting as changes to the values and mistakenly syncing the changes to other clients.
For example, a device that has limited capacity may truncate strings to save space—limit all strings to 12 characters or less—or reformat phone numbers to a preferred style. Records that are changed in this way are called formatted records. Typically, you do not want the sync engine to interpret format changes as changes to actual property values and push them to all other clients.
Therefore, if you change the format of a pulled record, you need to notify the sync engine when accepting the record as follows. First you create an NSDictionary containing the key-value pairs of the formatted properties and add the ISyncRecordEntityNameKey
key to specify the record’s entity name. Then you pass this dictionary as the formattedRecord argument to clientAcceptedChangesForRecordWithIdentifier:formattedRecord:newRecordIdentifier:
. Thereafter, the sync engine remembers the client’s formatted values and does not generate false changes during a slow sync.
NSDictionary *formattedRecord = |
[NSDictionary dictionaryWithObjectsAndKeys: |
entityName, ISyncRecordEntityNameKey, |
[myRecord valueForKey:@"title"], @"title", nil]; |
[session clientAcceptedChangesForRecordWithIdentifier:recordIdentifier |
formattedRecord:formattedRecord |
newRecordIdentifier:nil]; |
© 2004, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-10-31)