Reputation: 35050
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?!
Upvotes: 7
Views: 1192
Reputation: 30575
__defaultOwner__
mean's it's owned by the currently logged in iCloud account. So you could could check for that and display "Me" or the person's name if you have it. If you need to find out the logged-in user's recordID
you can use the async method: fetchUserRecordIDWithCompletionHandler
.
Upvotes: 8
Reputation: 5
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);
}];
}
}
}];
}
Upvotes: -2