CloudKit bytes to array of strings

185 views Asked by At

I have a record on my CloudKit public database that was made via the NSPersistentCloudKitContainer. In Core Data, the attribute is of type [String] and when I add it to the public database, it is converted to Bytes.

When I fetch this record and try to extract the [String] like so

strings = record["CD_strings"] as! [String]

I get the following error:

Could not cast value of type '_NSInlineData' (0x7fe5ae87c2a8) to 'NSArray' (0x7fe5ad835f90).

How are you supposed to get the CKRecordValue as type [String]?

1

There are 1 answers

0
Joao Pires On

All you need to do is to have the attribute type as transformable, add NSSecureUnarchiveFromData in the transformer field and [String] in Custom Class:

Like so...