This question asks whether one can use subscripting with CKRecord
in Swift. While I already knew how to do what the questioner wanted, every permutation of it g
Here’s a simple extension to CKRecord to make it easier to subscript with.
extension CKRecord {
struct Sub {
let record: CKRecord
subscript(key: String) -> CKRecordValue? {
get {
return record.objectForKey(key) as? CKRecordValue
}
set {
record.setObject(newValue, forKey: key)
}
}
}
var sub: Sub {
return Sub(record: self)
}
var