Ramesh
Ramesh

Reputation: 177

parse.com invalid type for key, expected map, but got array

i am newbie in Parse.in my Parse Table One Table Contain Location column and its type is object like as it is Shown in to Image.

enter image description here

Here i save An Array Value in to this Column like as

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];

Then it Give me Error like as invalid type for key Location, expected map, but got array (Code: 111, Version: 1.6.2).

Please Give me Solution for it.

Upvotes: 0

Views: 1614

Answers (1)

Lalji
Lalji

Reputation: 695

Why do you use object type? You should use GeoPoint.

if you wont to set NSArray than parse Datatype is Array not Object

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

Upvotes: 1

Related Questions