You don't need to do that with String, you can just cast to NSString like this:
`foo.setObject("smith" as NSString, forKey: "familyName")`
The reason I think is because previously in Swift 3 String would automatically be converted to NSString when needed, but now that's changed, and it's broken a lot of stuff. Now files are littered with massive amounts of casts. I've quickly gone from loving Swift 3 to despising it and I think Apple/the community made a bad move here.
It's not CloudKit that needs to be updated in any case, `CKRecordValue` is a protocol so it is the conforming objects that need to be updated.
The only way I can see to make it slightly less horrendous is by creating some extensions, but I think it's dumb it's the developer's responsibility for this given it's a standard framework.
extension String {
var CKRecordValue: CKRecordValue {
return self as NSString
}
}
extension Bool {
var CKRecordValue: CKRecordValue {
return self as NSNumber
}
}
extension Int {
var CKRecordValue: CKRecordValue {
return self as NSNumber
}
}
extension Data {
var CKRecordValue: CKRecordValue {
return self as NSData
}
}