ios - CloudKit - Storing multiple CKReferences in a CKRecord -
in app, have record type (useractivity) stores images user wants save profile. record type contains single attribute - ckreference record type (recordtypea example). works perfectly...i'm able store , retrieve data via references construct images , display appropriately on screen. however, realized need add second attribute useractivity record type, ckreference different record type (call recordtypeb). record type b second kind of image needs separately identified. each row in useractivity have 1 of 2 possible ckreferences, not both.
i can save new recordtypeb reference no problem, have couple of issues result. first, when save it, whether through code or ckdashboard, record shows title "no name" because there nothing attribute recordtypea. originally, record names ref:followed-by-recordid. works did if ua record has reference recordtypea. there way make create record name recordtypeb reference only? possible should change ckreference list have 2nd attribute? secondly, , more importantly, when i'm retrieving useractivity records, how can tell given record if contains reference recordtypea or recordtypeb? there way similar iskindofclass method? in case, method shows it's ckreference , not record type it's reference to. , maybe second question automatically solved if ckreference list appropriate solution? in advance guidance!
experience shows title of record first field created recordtype. haven't found documentation coincidence. if want title recordtypeb field, recreate recordtype , first create recordtypeb. there no other way influence title be.
you change ckreference list, think in case easier keep 2 separate fields. when don't mind item should use list. in case references 2 different types.
if did not write 1 of fields, when read record , @ reference, should nil. can't ask recordtype of ckreference. if create field reference, know recordtype should be. otherwise need create field indicating recordtype is.
Comments
Post a Comment