Well, I had a similar problem saving the information to a JSON file and had to rebuild the dictionary without the CLLocationCoordinate2D struct, before NSJSONSerialization would serialize the dictionary.
The reason I think it's a struct is that's how it's defined in CLLocation.h and right now in the debugger, annotation is showing as (struct objc_object * const), which sorta conflicts with what you wrote (TTBOMK). Here are the details from CLLocation.h: /* * CLLocationCoordinate2D * * Discussion: * A structure that contains a geographical coordinate. * * Fields: * latitude: * The latitude in degrees. * longitude: * The longitude in degrees. */ typedef struct { CLLocationDegrees latitude; CLLocationDegrees longitude; } CLLocationCoordinate2D; On May 8, 2012, at 5:27 PM, Jens Alfke wrote: > > On May 8, 2012, at 2:08 PM, Alex Zavatone wrote: > >> I've noticed problems before with structs and NSJSONSerializaion. >> I was trying to write out a dictionary (or array) of the contents of >> mapView.annotations, yet writeDictToFile fails, while it writes a simple >> dict just fine. >> Is there a problem with the structs within the annotations, namely, the >> CLLocationCoordinate2D struct for each annotation, that prevents this from >> being able to be written out to a dictionary or array? > > I don’t know what you mean by ‘struct’ here — C structs aren’t Objective-C > objects, so they can’t appear in a Cocoa collection. > > I do know that NSJSONSerialization only supports data types defined in JSON, > i.e. NSDictionary, NSArray, NSString, NSNumber, NSNull. If your object tree > has instances of any other classes in it, the encoder will throw an exception. > > —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com