• 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: Mapkit annotation arrays and writing to a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mapkit annotation arrays and writing to a file


  • Subject: Re: Mapkit annotation arrays and writing to a file
  • From: Conrad Shultz <email@hidden>
  • Date: Tue, 08 May 2012 14:53:55 -0700

On 5/8/12 2:35 PM, Alex Zavatone wrote:
> 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:

No one disputes that CLLocationCoordinate2D is a struct.  What Jens is
saying is that you can't store an unwrapped struct in a Cocoa collection
- be it a dictionary, array, or set.

What's getting lost in translation here is that -annotations is an array
of objects of type id <MKAnnotation>.

What sort of object conforming to MKAnnotation are you adding to your
annotations array?  Whatever it is, it must have a -coordinate property.
 It is *this* property this is a CLLocationCoordinate2D struct.  This is
how the data is getting stored in a Cocoa collection.

In any event, I don't see how you could directly serialize your
annotation object to a JSON object for exactly the reason Jens described
(i.e. type incompatibility).

If you need to convert to JSON you could, for example, write an
NSValueTransformer that converts your id <MKAnnotation> to an
NSDictionary that is compliant with NSJSONSerialization requirements.

Assuming that you are planning on using JSON to communicate with a web
service, though, you will need to determine what data structure the
service is expecting and emit that.


--
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
_______________________________________________

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

  • Follow-Ups:
    • Re: Mapkit annotation arrays and writing to a file
      • From: Alex Zavatone <email@hidden>
References: 
 >Mapkit annotation arrays and writing to a file (From: Alex Zavatone <email@hidden>)
 >Re: Mapkit annotation arrays and writing to a file (From: Jens Alfke <email@hidden>)
 >Re: Mapkit annotation arrays and writing to a file (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: iOS launch Music app?
  • Next by Date: Re: Mapkit annotation arrays and writing to a file
  • Previous by thread: Re: Mapkit annotation arrays and writing to a file
  • Next by thread: Re: Mapkit annotation arrays and writing to a file
  • Index(es):
    • Date
    • Thread