• 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: Moving Properties to
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving Properties to


  • Subject: Re: Moving Properties to
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 7 Nov 2010 14:16:12 -0800

On Nov 7, 2010, at 14:00, Kevin Bracey wrote:

> I may have painted myself into a corner with this one. To facilitate exporting my model objects as xml, I have my object properties stored in a NSDictionary, this makes for an easy export, both as plist and xml, I just walk the dictionary adding nodes. I have to maintain a lot of setters and getters and would like to @synthesize these, and do away with the NSDictionary.
>
> Is there any way to change my exportAsXML message to examine self to get a list of the @synthesize properties? Then loop through those and get there values?

You *can* use an Objective-C runtime to iterate through all your class's properties and you *can* tell whether each was defined by @synthesize or not, but I wouldn't recommend it. The problem is that you don't know which properties *not* defined by you might not produce a false positive (for example, an inherited syntehesized property).

I think a better approach is for your exportAsXML method to define an array of the property names you want to export, then iterate through the array with a 'for ... in' loop, using 'valueForKey:' to get the property values.


_______________________________________________

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: 
 >Moving Properties to (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: Ping host and port
  • Next by Date: Re: CATransaction setCompletionBlock - Nested Transactions bug?
  • Previous by thread: Moving Properties to
  • Next by thread: MapKit on iPad
  • Index(es):
    • Date
    • Thread