How can I iterate over an instance properties in objective-C ?
I need to get all the properties values 开发者_JAVA技巧without having to specify them.
This is the only solution I've found so far, but I was wondering if it could be done with less code: Get an object properties list in Objective-C
thanks
EDIT : @EmptyStack has the right idea - follow his link in the comments on the question :)
Take a look at these methods : http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/c/func/class_copyPropertyList
They let you (amongst other things) find all the properties that a class implements. You can then run through that array of properties and call performSelector:
for each property you are interested in.
精彩评论