How do I find all the property keys of a KVC compliant Objective-C object?
问题 Is there a method that returns all the keys for an object conforming to the NSKeyValueCoding protocol? Something along the lines of [object getPropertyKeys] that would return an NSArray of NSString objects. It would work for any KVC-compliant object. Does such a method exist? I haven't found anything in searching the Apple docs so far. Thanks, G. 回答1: #import "objc/runtime.h" unsigned int outCount, i; objc_property_t *properties = class_copyPropertyList([self class], &outCount); for(i = 0; i