Select to view content in your preferred language

AGSFeatureLayer crashing

3745
4
Jump to solution
02-21-2013 01:03 PM
DavidMcDonald2
Occasional Contributor
I am receiving an exception shortly after adding a feature layer to the map with a particular layer definition. I have attached the definition JSON that fails and two others that work ok. We're running ArcGIS IOS runtime version 10.1.1 and using a ArcGIS 10.1 server.

I am using the following code to test the layer definitions on their own (i.e. with an empty feature set). 

AGSFeatureSet *empty = [[AGSFeatureSet alloc] init]; AGSFeatureLayer *fl = [[AGSFeatureLayer alloc] initWithLayerDefinitionJSON:featureLayerDefinition featureSet:empty]]; [[self mapView] addMapLayer:fl withName:@"test"];



This is the exception is being thrown:

2013-02-18 16:02:58.917 Development[7570:c07] -[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678

2013-02-18 16:02:58.919 Development[7570:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678'

*** First throw call stack:

(0x30c7012 0x2e0fe7e 0x31524bd 0x30b6bbc 0x30b694e 0x17daac 0x180857 0x17f543 0x180857 0x181455 0x16f7f2 0x16f537 0x16e6c6 0x13fd7c 0x13cfef 0x30bb1bd 0x30bb0d6 0x2e236b0 0x1cf8765 0x304af3f 0x304a96f 0x306d734 0x306cf44 0x306ce1b 0x47747e3 0x4774668 0x2132ffc 0x14a6d 0x2fe5 0x1)

libc++abi.dylib: terminate called throwing an exception


Dave
0 Kudos
1 Solution

Accepted Solutions
DanaMaher
Regular Contributor

This is the exception is being thrown:

2013-02-18 16:02:58.917 Development[7570:c07] -[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678

2013-02-18 16:02:58.919 Development[7570:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678'

*** First throw call stack:

(0x30c7012 0x2e0fe7e 0x31524bd 0x30b6bbc 0x30b694e 0x17daac 0x180857 0x17f543 0x180857 0x181455 0x16f7f2 0x16f537 0x16e6c6 0x13fd7c 0x13cfef 0x30bb1bd 0x30bb0d6 0x2e236b0 0x1cf8765 0x304af3f 0x304a96f 0x306d734 0x306cf44 0x306ce1b 0x47747e3 0x4774668 0x2132ffc 0x14a6d 0x2fe5 0x1)

libc++abi.dylib: terminate called throwing an exception



The definition JSON you provided for that particular feature class has some nulls for keys that are supposed to have numerical values. The ArcGIS Runtime SDK inflates these as NSNull objects, and then AGSFeatureLayer's init method expects them to be NSNumbers. Hence, the unrecognized selector crash. I got your failing definition to work by pulling nulls out of fields that should be numerical values. I did not keep track of all of the nulls I pulled, two were for editFieldsInfo and ownershipBasedAccessControlForFeatures, and there were at least two more, but I have attached an updated version of the definition that will work in the 10.1.1 SDK. Sorry, hectic day at work and trying to fit this answer in at the end of lunch.

If you do not have a tool for working with large chunks of JSON, might I recommend JSON Editor Online, which is my go-to for working with ESRI service definitions.

View solution in original post

0 Kudos
4 Replies
DanaMaher
Regular Contributor

This is the exception is being thrown:

2013-02-18 16:02:58.917 Development[7570:c07] -[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678

2013-02-18 16:02:58.919 Development[7570:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull ags_CGFloatValue]: unrecognized selector sent to instance 0x31f8678'

*** First throw call stack:

(0x30c7012 0x2e0fe7e 0x31524bd 0x30b6bbc 0x30b694e 0x17daac 0x180857 0x17f543 0x180857 0x181455 0x16f7f2 0x16f537 0x16e6c6 0x13fd7c 0x13cfef 0x30bb1bd 0x30bb0d6 0x2e236b0 0x1cf8765 0x304af3f 0x304a96f 0x306d734 0x306cf44 0x306ce1b 0x47747e3 0x4774668 0x2132ffc 0x14a6d 0x2fe5 0x1)

libc++abi.dylib: terminate called throwing an exception



The definition JSON you provided for that particular feature class has some nulls for keys that are supposed to have numerical values. The ArcGIS Runtime SDK inflates these as NSNull objects, and then AGSFeatureLayer's init method expects them to be NSNumbers. Hence, the unrecognized selector crash. I got your failing definition to work by pulling nulls out of fields that should be numerical values. I did not keep track of all of the nulls I pulled, two were for editFieldsInfo and ownershipBasedAccessControlForFeatures, and there were at least two more, but I have attached an updated version of the definition that will work in the 10.1.1 SDK. Sorry, hectic day at work and trying to fit this answer in at the end of lunch.

If you do not have a tool for working with large chunks of JSON, might I recommend JSON Editor Online, which is my go-to for working with ESRI service definitions.
0 Kudos
DavidMcDonald2
Occasional Contributor
That's excellent, thank you very much. I had a feeling it was happening because of nulls or missing fields but my attempts to remove them hadn't worked, I should have persisted.

Cheers.
0 Kudos
DanaMaher
Regular Contributor
That's excellent, thank you very much. I had a feeling it was happening because of nulls or missing fields but my attempts to remove them hadn't worked, I should have persisted.

Cheers.


Hey, at least it's JSON and not XML 😄

You might mark one of my response as the answer in order to mark the entire thread as answered.
0 Kudos
DavidMcDonald2
Occasional Contributor
Is there any chance the runtime will be updated to support these null fields without crashing?
0 Kudos