parse.com键,预期映射的无效类型,但得到数组

时间:2015-01-31 06:56:48

标签: ios parse-platform

我是Parse的新手。在我的Parse Table One表中包含Location列,其类型为object,就像它显示在图像中一样。

enter image description here

这里我将一个数组值保存到此列中,如

NSDictionary *firstJsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                                         @"10.010490", @"latitude",
                                         @"76.360779", @"longitude",
                                         nil];
    NSMutableArray * arr = [[NSMutableArray alloc] init];
    [arr addObject:firstJsonDictionary];
PFObject *gameScore = [PFObject objectWithClassName:@"MapInfo"];
gameScore[@"Location"]=arr;
[gameScore saveInBackground];

然后就像我一样给我错误 invalid type for key Location, expected map, but got array (Code: 111, Version: 1.6.2)

请给我解决方案。

1 个答案:

答案 0 :(得分:1)

为什么使用对象类型?你应该使用GeoPoint。

如果你不设置NSArray而不是解析数据类型是数组不是对象

image

//Set Value
    PFObject * objLocationClass=[PFObject objectWithClassName:@"Class_Location"];

    PFGeoPoint * geoPoint=[PFGeoPoint geoPointWithLatitude:latitude longitude:longitude];
    [objLocation setObject:geoPoint forKey:@"location"];
//Get Value
    PFGeoPoint *userGeoPoint = (PFGeoPoint *)[objLocation valueForKey:@"location"];
    //userGeoPoint.latitude or userGeoPoint.longitude