Using NSCoder and NSKeyedArchiver with runtime reflection to deep copy a custom class
问题 I'd like to use - (id)initWithCoder:(NSCoder *)coder and - (void)encodeWithCoder:(NSCoder *)coder to encode a custom class for copying (using NSKeyedArchiver etc) My custom class contains a large number of iVars. Instead of listing all of these in the encoding code I'd like to use reflection to simply enumerate over all the properties in the custom class and encode/decode each property from within a loop. I'll end up with code that looks a bit like this: - (id)initWithCoder:(NSCoder *)coder {