2015-02-09 89 views
0

我正在嘗試使用AFNetworking調用parse.com REST API。 GET請求到目前爲止工作得很好。但是當談到創建對象時,我在創建兩個解析對象之間的關係(指向對象id的指針)時遇到了問題。使用AFNetworking通過REST API創建parse.com指針對象

我試過到目前爲止:

NSString* parameterString = [NSString stringWithFormat:@"{\"__op\":\"AddRelation\",\"objects\":[{\"__type\":\"Pointer\",\"className\":\"MyClass\",\"objectId\":\"%@\"}]}", myClassObjectId]; 

NSDictionary *parameters = @{@"myClass": parameterString}; 

[self.manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { ... }]; 

創建對象,而指針的工作也很好。我認爲錯誤與我的parameterString語法有關:

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)","code":111,"error":"invalid type for key myClass, expected *MyClass, but got string" 

任何想法?謝謝;)

回答

0

我得到了答案,最後:

NSDictionary *params = @{@"myClass":@{@"__type":@"Pointer", @"className":@"MyClass", @"objectId":[foobar objectID]}}; 
[self.manager POST:url parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { ... }]; 

所以...只是普通的JSON。