本篇主要是Protocol、SEL相关的方法调用
#pragma mark - IBAction
- (IBAction)logRunTimeAction:(id)sender {
objc_property_attribute_t attrs[] = { { "T", "@\"NSString\"" }, { "&", "N" }, { "V", "" } };
size_t objSize = class_getInstanceSize([_person class]);
size_t allocSize = 2 * objSize;
uintptr_t ptr = (uintptr_t)calloc(allocSize, 1);
// Sel
[self sel_getName:@selector(sel_getName:)];
[self sel_registerName:"runtimeTestAction3"];
[self sel_getUid:"runtimeTestAction3"];
[self sel_isEqual:@selector(runtimeTestAction3) sel2:@selector(runtimeTestAction2)];
// Protocol
[self protocol_getName:protocol];
[self protocol_getProperty:NSProtocolFromString(@"RuntimeBaseProtocol") name:"protocolString" isRequiredProperty:YES isInstanceProperty:YES];
Protocol *testProtocol = [self objc_allocateProtocol:"TestProtocol"];
[self protocol_addProperty:testProtocol name:"newProperty" attributes:attrs attributeCount:3 isRequiredProperty:YES isInstanceProperty:YES];
[self protocol_addProtocol:testProtocol addition:protocol];
[self protocol_addMethodDescription:testProtocol sel:@selector(runtimeTestAction3) types:"v@:" isRequiredMethod:NO isInstanceMethod:YES]; // 已注册的协议无法添加
[self objc_registerProtocol:testProtocol];
[self protocol_copyPropertyList:testProtocol];
[self protocol_copyProtocolList:testProtocol];
[self protocol_copyMethodDescriptionList:testProtocol isRequiredMethod:NO isInstanceMethod:YES];
[self protocol_isEqual:testProtocol other:protocol];
[self protocol_conformsToProtocol:testProt