Property printing

Hey, here’s a handy snippet:

Objective-C Quickie : Printing all declared properties of an object

Here’s some quick code that will print the values of all declared properties of an object using some of the introspection features of the runtime … As you can see, I’m using this so that NSLog will give me something meaningful by overriding the description method of NSObject…

Yes, using that will save a good bit of time compared to the rather annoying process of constructing a -description override for something with a veritable plethora of properties (and they always do when you need one, don’t they?), indeed!

h/t: @pzearfoss!

Alex | April 23, 2011

Leave a Reply