In the documents it says that CloudKit public databases will be available to read even if the user did not login with a proper iCloud account. However, I cannot fetch anything from my cloud database if i didn't connect my iOS simulator or device to iCloud. When i activate my iCloud account I am able to fetch data from my public database. If anyone who has an answer or same problem with me could answer that would be great. Thanks.
CKDatabase *publicDatabase = [[CKContainer containerWithIdentifier:@"mycontainer"] publicCloudDatabase];
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:@"idofmyrecord"] ;
[publicDatabase fetchRecordWithID:recordID completionHandler:^(CKRecord *fetchedRecord, NSError *error) {
if(!error){
NSLog(@"****Success***** %@",fetchedRecord[@"field1"]);
}else{
NSLog(@"****Failed***** %@",fetchedRecord[@"field2"]);
}
}];
fetchRecordWithIDmethod without be logged in, what doescontainerWithIdentifierreturn? - Jánospo [CKContainer containerWithIdentifier:@"mycontainer"]- Ersin SezginaccountStatusWithCompletionHandlermethod to see its status. - János