该参数期望NSDictionary
将转换为 URL 中的键/值对。因此,密钥很简单,但是在将其设置到字典中之前,您需要将其转换为 JSON 的值...
NSDictionary *jsonDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
@"Sean Plott", @"playerName",
[NSNumber numberWithBool:NO], @"cheatMode", nil];
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDictionary options:0 error:&error];
if (!jsonData) {
NSLog(@"NSJSONSerialization failed %@", error);
}
NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSDictionary *parameters = [[NSDictionary alloc] initWithObjectsAndKeys:
json, @"where", nil];
如果我们假设您的客户端配置了这样的东西(通常您是子类AFHTTPClient
并且可以将这些东西移动到里面
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.parse.com/"]];
[client setDefaultHeader:@"X-Parse-Application-Id" value:@"Q82knolRSmsGKKNK13WCvISIReVVoR3yFP3qTF1J"];
[client setDefaultHeader:@"X-Parse-REST-API-Key" value:@"iHiN4Hlw835d7aig6vtcTNhPOkNyJpjpvAL2aSoL"];
[client registerHTTPOperationClass:[AFJSONRequestOperation class]];
然后你应该可以打电话
[client getPath:@"1/classes/GameScore"
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failed %@", error);
}];