- (Class)createClass:(NSString*)className{ NSString* kLXDkvoClassPrefix= @"NSKVONotifying_"; NSString * kvoClassName = [kLXDkvoClassPrefix stringByAppendingString: className]; Class observedClass = NSClassFromString(kvoClassName); if (observedClass) { return observedClass; } Class kvoClass = objc_allocateClassPair(NSClassFromString(className), kvoClassName.UTF8String, 0); objc_registerClassPair(kvoClass); return kvoClass; }
主要是两个函数objc_allocateClassPair函数,以及objc_registerClassPair函数,前者创建指定父类,后者注册
原文:http://www.cnblogs.com/wxm5558/p/5808772.html