我已经从文档中创建了这种关系,但是无论我做什么,我似乎总是会出错:

Error: invalid type for key storeId, expected relation<stores>, but got *stores (Code: 111, Version: 1.2.19)

解析代码:
PFQuery *query = [PFQuery queryWithClassName:@"stores"];
[query getObjectInBackgroundWithId:storeID block:^(PFObject *objects, NSError *error) {

    PFObject *myNumber = [PFObject objectWithClassName:@"users"];
    myNumber[@"user"] = @1;
    myNumber[@"udid"] = [UIDevice currentDevice].identifierForVendor.UUIDString;
    // Add a relation
    myNumber[@"storeId"] = objects;
    [myNumber saveInBackground];
}];

最佳答案

也许这会有所帮助吗?

[[myNumber relationForKey:@"storeId"] addObject:objects];

如果将objects设为单数,则可能有助于提高代码的可读性,因为它仅表示一个对象。如果您将其命名为比对象更具描述性的名称,也可能会有所帮助。

关于ios - 关系解析,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24745075/

10-09 21:53