针对iOS上的数字的REST API查询

针对iOS上的数字的REST API查询,ios,objective-c,rest,parse-platform,Ios,Objective C,Rest,Parse Platform,我正在尝试使用iOS和AFNetworking上的restapi根据parse中的“Number”字段查询一个表以进行调用。(我使用RESTAPI是因为它是一个跨平台的应用程序,不想为每个平台开发单独的API) 我可以查询字符串,但我似乎不能查询数字——我在这里做错了什么?哪些操作需要与字符串不同?这是我的密码: - (void)searchUsers { // NSDictionary *searchParameters = @{ @"where": @{@"objectId":

我正在尝试使用iOS和AFNetworking上的restapi根据parse中的“Number”字段查询一个表以进行调用。(我使用RESTAPI是因为它是一个跨平台的应用程序,不想为每个平台开发单独的API)

我可以查询字符串,但我似乎不能查询数字——我在这里做错了什么?哪些操作需要与字符串不同?这是我的密码:

- (void)searchUsers {
//        NSDictionary *searchParameters = @{ @"where": @{@"objectId": @"2vQpRb6aF8"} };  //This works perfectly, because its a string I'm searching against in Parse
//        NSDictionary *searchParameters = @{ @"where": @{@"email": @"01000100.swan@gmail.com"} }; // Again, this works perfectly - also a string
//        NSDictionary *searchParameters = @{ @"where=": @{@"age": @{@"$gte" : @900}}}; // This doesn't work - it returns all values in the table with seemingly no filter against age, when there should be no results where "age" is greater than 900.

        NSDictionary *searchParameters = @{ @"where": @{@"age": [NSNumber numberWithInt:25]}};  // Again, this doesn't work. There should be 5 results where age = 25, and yet none are returned
//         @{ @"where": @{@"age": @{@"$gte" : [NSNumber numberWithInt:18]}}}

        [self.requestManager GET:@"https://api.parse.com/1/classes/userFromFB" parameters:searchParameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
            NSLog(@"Search Result: %@", [responseObject description]);
        }

        failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            NSLog(@"Error: %@", [error description]);
        }];
}

如果您有任何关于在iOS上查询数字类型的帮助/提示或更好的示例,我们将不胜感激。谢谢你的阅读

检查您的分析仪表板并确认
age
的类型是一个数字。使用
[NSNumber numberwhithint:25]
保存
年龄时,仪表板中显示哪些数据?您可能正在将要解析的数据保存为int,但尝试将其检索为NSNumber

结果表明,问题出在对查询进行编码以进行解析。当使用带有查询约束的RESTAPI时,您必须将约束编码/传递为JSON(因此NSDictionary随后序列化为JSON),然后必须使用URL编码对JSON进行编码。我只是使用:对URL进行编码,并用它发出GET请求-效果很好

您是否尝试过发送带有数字值的字符串?例如
[nsstringwithformat:@“%i”,someIntVariable]
而不是您的
NSNumber
谢谢,我已经尝试过了。关于这个问题,请看我下面的回答