One Logo Pool Ball
CloudKit · IOS API REFERENCE

CKRecord

class · iOS 8.0+ · SDK 27.1

class CKRecord

Members (24)

method · iOS 8.0+

allTokens

TypeScript
allTokens(): Array<string>
Swift declaration
func allTokens() -> [String]
method · iOS 8.0+

encodeSystemFields

TypeScript
encodeSystemFields(coder: _Foundation_NSCoder): void
Swift declaration
func encodeSystemFields(with coder: NSCoder)
subscript · iOS 8.0+

subscript

TypeScript
subscript(key: string): (SDKHandle) | null
Swift declaration
subscript(key: String) -> (any __CKRecordObjCValue)? { get set }
method · iOS 10.0+

setParent

TypeScript
setParent(parentRecord?: (CKRecord) | null): void
Swift declaration
func setParent(_ parentRecord: CKRecord?)
method · iOS 10.0+

setParent

TypeScript
setParent16582(parentRecordID?: (CKRecord_ID) | null): void
Swift declaration
func setParent(_ parentRecordID: CKRecord.ID?)
get · iOS 8.0+

creationDate

TypeScript
get creationDate(): (globalThis.Date) | null
Swift declaration
var creationDate: Date? { get }
get · iOS 8.0+

creatorUserRecordID

TypeScript
get creatorUserRecordID(): (CKRecord_ID) | null
Swift declaration
@NSCopying var creatorUserRecordID: CKRecord.ID? { get }
get · iOS 15.0+

encryptedValues

TypeScript
get encryptedValues(): (SDKHandle) & (SDKHandle)
Swift declaration
@NSCopying var encryptedValues: any CKRecordKeyValueSetting & Sendable { get }
get · iOS 8.0+

lastModifiedUserRecordID

TypeScript
get lastModifiedUserRecordID(): (CKRecord_ID) | null
Swift declaration
@NSCopying var lastModifiedUserRecordID: CKRecord.ID? { get }
get · iOS 8.0+

modificationDate

TypeScript
get modificationDate(): (globalThis.Date) | null
Swift declaration
var modificationDate: Date? { get }
get · iOS 10.0+

parent

TypeScript
get parent(): (CKRecord_Reference) | null
Swift declaration
@NSCopying var parent: CKRecord.Reference? { get set }
set · iOS 10.0+

parent

TypeScript
set parent(value: (CKRecord_Reference) | null)
Swift declaration
@NSCopying var parent: CKRecord.Reference? { get set }
get · iOS 8.0+

recordChangeTag

TypeScript
get recordChangeTag(): (string) | null
Swift declaration
var recordChangeTag: String? { get }
get · iOS 8.0+

recordID

TypeScript
get recordID(): CKRecord_ID
Swift declaration
@NSCopying var recordID: CKRecord.ID { get }
get · iOS 10.0+

share

TypeScript
get share(): (CKRecord_Reference) | null
Swift declaration
@NSCopying var share: CKRecord.Reference? { get }
init · iOS 8.0+

init

TypeScript
static initRecordTypeRecordID(recordType: string, recordID?: CKRecord_ID): CKRecord
Swift declaration
convenience init(recordType: CKRecord.RecordType, recordID: CKRecord.ID = CKRecord.ID())

Creates a record using an ID that you provide. - Parameters: - recordType: A string that represents the type of record that you want to create. You can't change the record type after initialization. You define the record types that your app supports and use them to distinguish between records with different types of data. This parameter must not be `nil` or contain an empty string. A record type must consist of one or more alphanumeric characters and must start with a letter. CloudKit permits the use of underscores, but not spaces. - recordID: The ID to assign to the record. When creating the ID, you can specify the zone where you want to store the record. You should provide a value that is unique across all records and may not provide `nil`. Use this method to initialize a new record object with the specified ID. The newly created record contains no data. Upon creation, record objects exist only in memory on the local device. Save the record using a ``CKModifyRecordsOperation`` object or by using the ``CKDatabase/save(_:completionHandler:)-3tatz`` method to transfer the record's contents to the server.

init · iOS 8.0+

init

TypeScript
static initRecordTypeZoneID(recordType: string, zoneID: CKRecordZone_ID): CKRecord
Swift declaration
convenience init(recordType: CKRecord.RecordType, zoneID: CKRecordZone.ID)

Creates a record in the specified zone. @DeprecationSummary { Use ``CKRecord/init(recordType:recordID:)`` instead. } - Parameters: - recordType: A string that represents the type of record that you want to create. You can't change the record type after initialization. You define the record types that your app supports and use them to distinguish between records with different types of data. This parameter must not be `nil` or contain an empty string. A record type must consist of one or more alphanumeric characters and must start with a letter. CloudKit permits the use of underscores, but not spaces. - zoneID: The ID of the record zone where you want to store the record. Use this method to initialize a new record object with the specified ID. The newly created record contains no data. Upon creation, record objects exist only in memory on the local device. Save the record using a ``CKModifyRecordsOperation`` object or by using the ``CKDatabase/save(_:completionHandler:)-3tatz`` method to transfer the record's contents to the server.

get · iOS 8.0+

recordType

TypeScript
get recordType(): string
Swift declaration
var recordType: CKRecord.RecordType { get }

The value that your app defines to identify the type of record. Use this value to differentiate between different record types in your app. The value is primarily for your benefit, so choose record types that represent the data in the corresponding records. CloudKit provides two system-defined record types: | Record Type | Description | |---|---| | ``CKRecordTypeUserRecord-49k30`` | Identifies records that represent users. | | ``CKRecordTypeShare-8b6yt`` | Identifies records that the user shares. |

method · iOS 8.0+

changedKeys

TypeScript
changedKeys(): Array<string>
Swift declaration
func changedKeys() -> [CKRecord.FieldKey]

Returns an array of keys with recent changes to their values. - Returns: An array of keys with changed values since downloading or saving the record. If there aren't any changed keys, this method returns an empty array.

method · iOS 8.0+

makeIterator

TypeScript
makeIterator(): CKRecordKeyValueIterator
Swift declaration
func makeIterator() -> CKRecordKeyValueIterator

Returns an iterator of the record's key-value pairs.

method · iOS 8.0+

object

TypeScript
object(key: string): (SDKHandle) | null
Swift declaration
func object(forKey key: CKRecord.FieldKey) -> (any __CKRecordObjCValue)?

Returns the object that the record stores for the specified key. - Parameters: - key: The string that identifies a field in the record. A key must consist of one or more alphanumeric characters and must start with a letter. CloudKit permits the use of underscores, but not spaces. - Returns: The object for the specified key, or `nil` if no such key exists in the record. New records don't contain any keys or values. Values are always one of the data types in <doc:CKRecord#Supported-Data-Types>. You access the fields of a `CKRecord` object the same way you access key-value pairs in a dictionary. The `CKRecord` class defines the ``CKRecord/object(forKey:)`` and ``CKRecord/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 `firstName` field and retrieve a `lastName` field from a record: ```swift // Equivalent ways to get a value. var hiredAt = record.object(forKey: "hiredAt") hiredAt = record["hiredAt"] ```

method · iOS 8.0+

allKeys

TypeScript
allKeys(): Array<string>
Swift declaration
func allKeys() -> [CKRecord.FieldKey]

Returns an array of the record's keys. - Returns: An array of keys, or an empty array if the record doesn't contain any keys. The array contains only those keys with values that aren't `nil`.

method · iOS 8.0+

setObject

TypeScript
setObject(object: (SDKHandle) | null, key: string): void
Swift declaration
func setObject(_ object: (any __CKRecordObjCValue)?, forKey key: CKRecord.FieldKey)

Stores an object in the record using the specified key. - Parameters: - object: The object to store using the specified key. The value you provide must be an instance of one the data types in <doc:CKRecord#Supported-Data-Types>. You receive an error if you use a data type that CloudKit doesn't support. If you specify `nil`, CloudKit removes any object that the record associates with the key. - key: The key to associate with `object`. Use this key to retrieve the value later. A key must consist of one or more alphanumeric characters and must start with a letter. CloudKit permits the use of underscores, but not spaces. Avoid using a key that matches the name of any property of `CKRecord`. If the specified key already exists in the record, CloudKit deletes its previous value and replaces it with the one in the `object` parameter. This change affects only the local copy of the record. You must save the record to the server again before the change becomes available to other clients. If the type of the `object` parameter differs from the type of the object that's on the server, you encounter an error when you attempt to save this record to the server. For example, if the current value is an <doc://com.apple.documentation/documentation/foundation/nsstring> object, you receive an error if you change the value to an <doc://com.apple.documentation/documentation/foundation/nsnumber> object and save the record. You access the fields of a `CKRecord` object the same way you access key-value pairs in a dictionary. The `CKRecord` class defines the ``CKRecord/object(forKey:)`` and ``CKRecord/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 `firstName` field and get a `lastName` field from a record: ```swift // Equivalent ways to set a value. let record = CKRecord(recordType: "Employee") record.setObject(NSDate(), forKey: "hiredAt") record["hiredAt"] = NSDate() ```

subscript · iOS 8.0+

subscript

TypeScript
subscript3079(key: string): (SDKHandle) | null
Swift declaration
subscript(key: CKRecord.FieldKey) -> (any __CKRecordObjCValue)? { get set }

Returns the object that the record stores for the specified key. - Parameters: - key: The string that identifies a field in the record. A key must consist of one or more alphanumeric characters and must start with a letter. CloudKit permits the use of underscores, but not spaces. - Returns: The object for the specified key, or `nil` if no such key exists in the record.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

CKRecord.init()

inherited init: cannot prove legal (class declares 2 custom initializers)

All CloudKit types →