• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Guidelines on using NSJSONSerialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guidelines on using NSJSONSerialization


  • Subject: Re: Guidelines on using NSJSONSerialization
  • From: Alex Zavatone <email@hidden>
  • Date: Thu, 19 Apr 2012 13:59:49 -0400

On Apr 19, 2012, at 1:39 PM, Fritz Anderson wrote:

> On 19 Apr 2012, at 12:01 PM, Alex Zavatone wrote:
>
>> Yeah, it was the fact that the CLLocationDegrees in the CLLocationCoordinate2D struct were doubles, or that CLLocationCoordinate2D was a struct.
>
> Likely both. structs are not wrapped NSNumbers, NSStrings, NSArrays, NSDictionaries, or NSNulls, and doubles are not NSNumbers.
>
>> The other possibility might be if the mapView.annotations array  is nil terminated, that might cause the premature death.
>
> This confuses me. MKMapView.annotations is an NSArray. How can an NSArray be nil-terminated? It has a count and there's no way to index into it that would return anything but an object. There's no need and no way to terminate it.

Confused me too.  It might be how I am walking the array that creates a nil result, or a mistake in initialization but I ran into it yesterday as well, where the last value in the array was crashing Xcode until i did a check for nil and if the result was not nil, then process it.

>> Still think that NSJSONSerialization dataWithJSONObject:jAnnotations options:NSJSONWritingPrettyPrinted error:&error should throw an error rather than just crashing. Seems odd to have the error option there, but not usable.
>
> It's not magic. All methods that expect objects crash if you give them some other kind of pointer instead.

So, that either points to elves, or nil getting assigned to an array entry.

> If, however, jAnnotations is an NSArray, the method should be able to detect that its contents are not of the supported type. The method shouldn't crash.


It's got to be a nil value creeping into the annotation list somewhere.  Time to add some data validity checking loops.

Thanks Fritz.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Guidelines on using NSJSONSerialization (From: Alex Zavatone <email@hidden>)
 >Re: Guidelines on using NSJSONSerialization (From: Alex Zavatone <email@hidden>)
 >Re: Guidelines on using NSJSONSerialization (From: Fritz Anderson <email@hidden>)

  • Prev by Date: NSDate value set in one method, vanishes when accessed from another
  • Next by Date: Re: NSDate value set in one method, vanishes when accessed from another
  • Previous by thread: Re: Guidelines on using NSJSONSerialization
  • Next by thread: Re: Guidelines on using NSJSONSerialization
  • Index(es):
    • Date
    • Thread