解析中的关系

时间:2014-07-14 20:10:50

标签: ios objective-c parse-platform

我已经从文档中创建了这种关系,但无论我做什么,我似乎都会收到错误:

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];
}];

1 个答案:

答案 0 :(得分:4)

也许这会有所帮助?

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

如果您使objects单数形式,它可能有助于您的代码的易读性,因为它只代表一个对象。如果你将它命名为比对象更具描述性的东西,它也会有所帮助。