Instance Method


Returns the value for the given key stored in the record.


- (__kindof id<CKRecordValue>)objectForKey:(CKRecordFieldKey)key;



The string that identifies a field in the record. Key names consist of one or more alphanumeric characters and start with a letter. You may also include underscore characters if you do not use an underscore as the first character in the name. Spaces are not allowed in key names.

Return Value

The object associated with the specified key or nil if no such key exists in the record.


New records do not contain any keys or values initially. Values are always one of the object types listed in Supported Data Types.

You access the fields of a CKRecord object the same way you access key-value pairs in an NSMutableDictionary. The CKRecord class defines the objectForKey: and setObject:forKey: methods for getting and setting values. It also supports dictionary index notation. The following example shows how to use both techniques to set a field named firstName and get a field named lastName from a given record.

// Equivalent ways to get a value.
id value = [myRecord objectForKey:@"hiredAt"];
value = myRecord[@"hiredAt"];

See Also

Accessing the Record’s Fields

- setObject:forKey:

Sets the value for the specified key.

- objectForKeyedSubscript:

Returns the value for the given key stored in the record.

- setObject:forKeyedSubscript:

Adds the specified key-value pair to the record.

- allKeys

Returns an array of strings corresponding to all keys currently in the record.

- changedKeys

Returns an array of strings representing the keys that have changed recently.