我是Parse的新手。在我的Parse Table One表中包含Location
列,其类型为object
,就像它显示在图像中一样。
这里我将一个数组值保存到此列中,如
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)
。
请给我解决方案。
答案 0 :(得分:1)
为什么使用对象类型?你应该使用GeoPoint。
如果你不设置NSArray而不是解析数据类型是数组不是对象
//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