creatorUserRecordID.recordName contains “__defaultOwner__” instead of UUID shown in Dashboard

二次信任 提交于 2019-12-05 09:50:48

"__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);
                }];
            }
        }
    }];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!