Downloading a CKRecord
from CloudKit
and when plotting creator recordName
, I can see this:
(lldb) po record.creatorUserRecordID.recordName
__defaultOwner__
but, Dashboard show a real value.
Why the difference?!
I hope I do not have to download only because of this the logged in user first?!
"__defaultOwner__" mean's its owned by the currently logged in iCloud account. So you could replace that with "Me" or the person's name if you have it. If you want to find out the logged in user's recordID you can use the asynchronous method fetchUserRecordIDWithCompletionHandler.
Jay
it is a bug
edit this:
- (void)postMoodFeed:(NSString *)moodFeed
{
CKRecord *moodRecord = [[CKRecord alloc] initWitenter code herehRecordType:@"Mood"];
moodRecord[@"moodFeed"] = moodFeed`enter code here`
[[[CKContainer defaultContainer] publicCloudDatabase] saveRecord:moodRecord completionHandler:^(CKRecord *record, NSError *error) {
[self queryMyMood];
}];
}
- (void)queryMyMood
{
// currentUserRecordID is fetched from fetchUserRecordIDWithCompletionHandler: of CKContainer
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"creatorUserRecordID = %@", currentUserRecordID];
CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Mood" predicate:predicate];
[[[CKContainer defaultContainer] publicCloudDatabase] performQuery:query inZoneWithID:nil completionHandler:^(NSArray *results, NSError *error) {
if (results) {
for (CKRecord *eachRecord in results) {
// Following logs are all __defaultOwner__
NSLog(@"%@", eachRecord.creatorUserRecordID.recordName);
[[[CKContainer defaultContainer] publicCloudDatabase]fetchRecordWithID:eachRecord.creatorUserRecordID completionHandler:^(CKRecord *record, NSError *error) {
// All following logs are "Unknown item" error
NSLog(@"%@", error);
}];
}
}
}];
}
来源:https://stackoverflow.com/questions/30502271/creatoruserrecordid-recordname-contains-defaultowner-instead-of-uuid-shown