I am using the code below to fetch a CKAsset List but it keeps crashing and telling me: "fatal error: unexpectedly found nil while unwrapping an Optional value" However the asset list is not empty in the CloudKit dashboard.
Do you know where I am going wrong?
var imageAssets = record.value(forKey: "membersPhotos") as! [CKAsset]
Thanks
You are forced unwrapping of the
record.value(forKey: "membersPhotos")it is bad practice.To avoid this use
if letorguardconditions to always know with witch type you are working on.Example :