I inserted debug statement and got bunch of output. I could not figure out anything. So I deleted the app from my phone, and that should have deleted the local core data except icloud data. Then I connected the phone and ran again, the deleted records were retrieved from cloud kit. So that means it exists on cloud kit. However when I go to cloudKit and query for that CkRecord in public database it does not return any records. However it is retrieved from cludkit The debug console shows:
Importing updated records:
"<CKRecord: 0x1371117d0; recordType=CD_Contact, recordID=C8665C72-1489-4A5B-A862-D8C74219B5AC:(com.apple.coredata.cloudkit.zone:defaultOwner), recordChangeTag=ly, values={\n "CD_email" = E;\n "CD_entityName" = Contact;\n "CD_firstName" = V;\n "CD_imageName_ckAsset" = "<CKAsset: 0x13710b2a0; referenceSignature={length = 21, bytes = 0x016f67dfd0e6f5e95265715be55e67638763588cb7}, uploadRank=0, path=/private~/Library/Caches/CloudKit/ddfda053c3b06e4b4fc14067715eb6799399b480/Assets/059AD8FD-1A39-4AA9-83F5-2114E670D8F6.011ae0acd6179011e5f5b153e01a6b8b6b3146912b, size=3241087, UUID=059AD8FD-1A39-4AA9-83F5-2114E670D8F6, signature={length = 21, bytes = 0x011ae0acd6179011e5f5b153e01a6b8b6b3146912b}, wrappedAssetKey=<24 bytes>>";\n "CD_lastName" = R;\n "CD_phone" = 2;\n "CD_screenName" = Be;\n "CD_uniqueId" = "102B2E06-79B5-45E7-A01C-2169412D08FB-4156-0000015E1DE289BE";\n "CD_userRating" = "*****";\n "CD_userType" = Household;\n}>"
I was puzzled as to why cloudKit does not show any records. I have indexed recordName as Queryable, modifiedTimeStamp as queryable and sortable. I have only one defaultZone.
By chance I decided to check private database and queried records from private database and lo and behold they were all there. So why are my records going to private database instead of public database. I have posted all my code above and nowhere you can see I have configured private database store. In fact I am using default code provided by Apple and some code from net and I assumed it would go to public database. Can you clarify why it is going to private database and how to point it to public database. I do want some records to go to private database though. So I Need the option to synchronize some data to public and some to private database. How to do this?