使用runtime 深拷贝
作者:
张霸天 | 来源:发表于
2016-12-11 10:50 被阅读0次- (void)copy:(NSObject *)object {
unsigned int property_count = 0;
objc_property_t * propertys = class_copyPropertyList([object class], &property_count);
for (int i = 0; i < property_count; i++) {
objc_property_t property = propertys[i];
const char * property_name = property_getName(property);
NSString * property_name_string = [NSString stringWithUTF8String:property_name];
[self setValue:[object valueForKey:property_name_string] forKey:property_name_string];
}
free(propertys);
}
本文标题:使用runtime 深拷贝
本文链接:https://www.haomeiwen.com/subject/bixpmttx.html
网友评论