Below is my Response
geolocation = {
loc = {
lat = "22.4409980000000004451976565178";
long = "70.0686230000000023210304789245";
};
};
My app crashes when I try below code:
NSNumber* n = [userPin valueForKeyPath:@"geolocation.loc.lat"];
NSLog(@"num is class %@", NSStringFromClass([n class]));
float fCost = [n floatValue];
When I print my NSStringFromClass I get __NSSingleObjectArrayI.
Any suggestion how to fix this?
At a guess the (runtime) type of
userPinis array and it contains one element. When applied to an arrayvalueForKey:, on whichvalueForKeyPath:is based, returns an array produced by applying itself to every element of the array.If this is the case either index
userPinbefore the call or handle the array resulting from the call.Addendum
Trivial example:
Produces:
showing
resultis an array of the result of applyinglengthto each element of `test. HTH