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 (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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com