ios - Automatically copy property values from one object to another of a different type but the same protocol (Objective-C) -


I have two classes with the properties of the same set, declared in the protocol using the @ Property Directive, they both execute Now I was thinking that with the values ​​of second class (and vice versa) with values, it is possible to automatically populate an example of the first class. I would like to strengthen this approach, so that if I change the declared properties in the protocol, there will be no need to add additional code in the copying methods.

Yes, there may be different approaches to this problem.

I can think that the properties of all source objects for the first time, then use the setValue: value for Key: key to set the value on the target object.

Code to retrieve all custom properties:

  - (NSSet *) Property Name {NSMutableSet * propNames = [NSMutableSet set]; Unsigned int outCount, i; Objc_property_t * Properties = class_copyPropertyList ([self class], & amp; outer number); For (i = 0; i & lt; outCount; i ++) {objc_property_t Properties = Properties [i]; NSString * propertyName = [[[NSString alloc] initWithCString: property_getName (property)] autoresphere]; [Propane names addObject: propertyName]; } Free (quality); Return Propane Name; }   

You may want to checkout for more information.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -