如何访问cloudKit用户中的每个属性。我有一个用于获取的记录ID数组。我在一本字典中找回记录(本例中为2)。
NSMutableArray *recordIDs;
for (NSString *recordName in recordNames) {
CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:recordName];
[recordIDs addObject:recordID];
}
CKFetchRecordsOperation *fetchOperation = [[CKFetchRecordsOperation alloc] initWithRecordIDs:recordIDs];
fetchOperation.fetchRecordsCompletionBlock = ^(NSDictionary /* CKRecordID * -> CKRecord */ *recordsByRecordID, NSError *operationError) {
NSLog(@"recordsByRecordID %@", recordsByRecordID);
};
控制台记录以下内容:
2015-04-11 11:04:15.829 projectName[10154:555807] recordsByRecordID {
"<CKRecordID: 0x7fea3bd86f80; _c835c6d554eafe23xxxxb65a1a9dd94d:(_defaultZone:__defaultOwner__)>" = "<CKRecord: 0x7fea44596fc0; recordType=Users, recordID=_c835c6d554eafe23xxxxb65a1a9dd94d:(_defaultZone:__defaultOwner__), recordChangeTag=i7rxe5ce, values={\n identifier = \"3E7837F6-C23C-44B2-89E8-5D9DF9AB061E\";\n points = 50;\n username = \"_c835c6d554eafe23xxxxb65a1a9dd94d\";\n}>";
"<CKRecordID: 0x7fea3e0614d0; _cd5f8486186028eaxxx6b6597489619:(_defaultZone:__defaultOwner__)>" = "<CKRecord: 0x7fea3e2567a0; recordType=Users, recordID=_cd5f8486186028eaxxx6b6597489619:(_defaultZone:__defaultOwner__), recordChangeTag=i7s7706j, values={\n identifier = \"4B3B374E-42B0-47B7-8638-A8967C23FA21\";\n points = 250;\n username = \"_cd5f8486186028eaxxx6b6597489619\";\n}>";
}
我想检索用户名和点并将其添加到本地词典。
答案 0 :(得分:0)
我明白了。看起来我需要为每条记录传递recordID然后传入要检索的密钥。
for (CKRecordID *recordID in recordsByRecordID) {
NSString *pointsString = recordsByRecordID[recordID][PointsKey];
NSLog(@"string %@", pointsString);
}