├── HCDExtension1 ├── HCDExtension.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension2 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension3 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension4 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+HCDKeyValueObject.h │ ├── NSObject+HCDKeyValueObject.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension5 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+HCDKeyValueObject.h │ ├── NSObject+HCDKeyValueObject.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension6 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+HCDKeyValueObject.h │ ├── NSObject+HCDKeyValueObject.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDStatus.h │ ├── HCDStatus.m │ ├── HCDUser.h │ ├── HCDUser.m │ └── main.m ├── HCDExtension7 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── Ad.h │ ├── Ad.m │ ├── BaseObject.h │ ├── BaseObject.m │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+HCDKeyValueObject.h │ ├── NSObject+HCDKeyValueObject.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDStatus.h │ ├── HCDStatus.m │ ├── HCDUser.h │ ├── HCDUser.m │ ├── IDAndDescription.h │ ├── IDAndDescription.m │ ├── Status.h │ ├── Status.m │ ├── StatusResult.h │ ├── StatusResult.m │ └── main.m ├── HCDExtension8 ├── HCDExtension.xcodeproj │ ├── .LSOverride │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── HCDExtension.xccheckout │ │ └── xcuserdata │ │ │ └── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── huangchengdu.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── HCDExtension.xcscheme │ │ └── xcschememanagement.plist └── HCDExtension │ ├── Ad.h │ ├── Ad.m │ ├── BaseObject.h │ ├── BaseObject.m │ ├── HCDExtensionSource │ ├── HCDExtensionConst.h │ ├── HCDExtensionConst.m │ ├── HCDProperty.h │ ├── HCDProperty.m │ ├── HCDPropertyType.h │ ├── HCDPropertyType.m │ ├── NSObject+HCDKeyValueObject.h │ ├── NSObject+HCDKeyValueObject.m │ ├── NSObject+Property.h │ └── NSObject+Property.m │ ├── HCDStatus.h │ ├── HCDStatus.m │ ├── HCDUser.h │ ├── HCDUser.m │ ├── IDAndDescription.h │ ├── IDAndDescription.m │ ├── Status.h │ ├── Status.m │ ├── StatusResult.h │ ├── StatusResult.m │ ├── User.h │ ├── User.m │ └── main.m ├── IMP指针的作用 ├── IMP指针的作用.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ ├── IMP指针的作用.xcscheme │ │ └── xcschememanagement.plist ├── IMP指针的作用 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── UIViewController+IMPCategory.h │ ├── UIViewController+IMPCategory.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── IMP指针的作用Tests │ ├── IMP_____Tests.m │ └── Info.plist ├── LICENSE ├── OC消息转发实践 ├── NSArraySwizzing │ ├── NSArraySwizzing.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── NSArraySwizzing.xccheckout │ │ │ └── xcuserdata │ │ │ │ └── yifan.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── NSArraySwizzing.xcscheme │ │ │ └── xcschememanagement.plist │ ├── NSArraySwizzing │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.xib │ │ │ └── Main.storyboard │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── NSArray+Swizzle.h │ │ ├── NSArray+Swizzle.m │ │ ├── ViewController.h │ │ ├── ViewController.m │ │ └── main.m │ └── NSArraySwizzingTests │ │ ├── Info.plist │ │ └── NSArraySwizzingTests.m └── UIViewControllerSwizzing │ ├── OC消息转发.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── OC消息转发.xccheckout │ │ └── xcuserdata │ │ │ ├── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ │ ├── OC消息转发.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ ├── OC消息转发.xcscheme │ │ └── xcschememanagement.plist │ ├── OC消息转发 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── UIViewController+HCDMethodSwizzling.h │ ├── UIViewController+HCDMethodSwizzling.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m │ └── OC消息转发Tests │ ├── Info.plist │ └── OC____Tests.m ├── Objective-C Runtime原理 ├── Objective-C Runtime原理.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── Objective-C Runtime原理.xccheckout │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ ├── Objective-C Runtime原理.xcscheme │ │ └── xcschememanagement.plist ├── Objective-C Runtime原理 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── Objective-C Runtime原理Tests │ ├── Info.plist │ └── Objective_C_Runtime__Tests.m ├── Objective-C消息发送和消息转发机制的实现 ├── Objective-C消息发送和消息转发机制的实现.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ ├── Objective-C消息发送和消息转发机制的实现.xcscheme │ │ └── xcschememanagement.plist └── Objective-C消息发送和消息转发机制的实现 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── CompanyModel.h │ ├── CompanyModel.m │ ├── Info.plist │ ├── PersonModel.h │ ├── PersonModel.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── README.md ├── iOS~runtime理解 ├── iOS~runtime理解.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── iOS~runtime理解.xccheckout │ │ └── xcuserdata │ │ │ ├── huangchengdu.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── yifan.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── huangchengdu.xcuserdatad │ │ └── xcschemes │ │ │ ├── iOS~runtime理解.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── yifan.xcuserdatad │ │ └── xcschemes │ │ ├── iOS~runtime理解.xcscheme │ │ └── xcschememanagement.plist ├── iOS~runtime理解 │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── iOS~runtime理解Tests │ ├── Info.plist │ └── iOS_runtime__Tests.m └── 自己动手实现 KVO ├── 自己动手实现 KVO.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── yifan.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── yifan.xcuserdatad │ └── xcschemes │ ├── xcschememanagement.plist │ └── 自己动手实现 KVO.xcscheme ├── 自己动手实现 KVO ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── main.m └── 自定义KVO │ ├── HCDObservationInfo.h │ ├── HCDObservationInfo.m │ ├── NSObject+HCDKVO.h │ └── NSObject+HCDKVO.m ├── 自己动手实现 KVOTests ├── Info.plist └── _______KVOTests.m └── 自己动手实现 KVOUITests ├── Info.plist └── _______KVOUITests.m /HCDExtension1/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension1/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension/HCDExtensionSource/NSObject+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Property.h" 10 | #import 11 | /** 12 | * 次结构体是一个属性列表的对象 13 | */ 14 | typedef struct property_t { 15 | const char *name; 16 | const char *attributes; 17 | } *propertyStruct; 18 | 19 | @implementation NSObject (Property) 20 | +(NSArray *)properties{ 21 | NSArray *propertiesArray = [NSMutableArray array]; 22 | //1 获取所有的属性 23 | unsigned int outCount = 0; 24 | objc_property_t *properties = class_copyPropertyList(self, &outCount); 25 | 26 | for (int i = 0; i < outCount; i++) { 27 | //去除一条属性 28 | objc_property_t property = properties[i]; 29 | //属性名 30 | NSString *name = @(property_getName(property)); 31 | //得到属性的各种信息 32 | NSString *attributes = @(property_getAttributes(property)); 33 | NSUInteger loc = 1; 34 | NSUInteger len = [attributes rangeOfString:@","].location - loc; 35 | NSString *type = [attributes substringWithRange:NSMakeRange(loc, len)]; 36 | NSLog(@"name:%s---attributes:%s",property_getName(property), 37 | property_getAttributes(property)); 38 | NSLog(@"name:%s---attributes:%s",((propertyStruct)property)->name,((propertyStruct)property)->attributes); 39 | NSLog(@"%@",type); 40 | 41 | } 42 | 43 | return propertiesArray; 44 | } 45 | @end 46 | 47 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension1/HCDExtension/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | #import "NSObject+Property.h" 12 | int main(int argc, const char * argv[]) { 13 | @autoreleasepool { 14 | 15 | NSArray *propertyArray = [HCDUser properties]; 16 | NSLog(@"%@",propertyArray); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension2/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension2/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/HCDPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPropertyType.h" 10 | 11 | @implementation HCDPropertyType 12 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string{ 13 | return [[HCDPropertyType alloc] initWithTypeString:string]; 14 | } 15 | 16 | - (instancetype)initWithTypeString:(NSString *)string 17 | { 18 | if (self = [super init]) 19 | { 20 | NSUInteger loc = 1; 21 | NSUInteger len = [string rangeOfString:@","].location - loc; 22 | NSString *type = [string substringWithRange:NSMakeRange(loc, len)]; 23 | 24 | NSLog(@"%@",type); 25 | } 26 | return self; 27 | }@end 28 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDExtensionSource/NSObject+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Property.h" 10 | #import 11 | #import "HCDProperty.h" 12 | /** 13 | * 次结构体是一个属性列表的对象 14 | */ 15 | typedef struct property_t { 16 | const char *name; 17 | const char *attributes; 18 | } *propertyStruct; 19 | 20 | @implementation NSObject (Property) 21 | +(NSArray *)properties{ 22 | NSArray *propertiesArray = [NSMutableArray array]; 23 | //1 获取所有的属性 24 | unsigned int outCount = 0; 25 | objc_property_t *properties = class_copyPropertyList(self, &outCount); 26 | 27 | // for (int i = 0; i < outCount; i++) { 28 | // //去除一条属性 29 | // objc_property_t property = properties[i]; 30 | // //属性名 31 | // NSString *name = @(property_getName(property)); 32 | // //得到属性的各种信息 33 | // NSString *attributes = @(property_getAttributes(property)); 34 | // NSUInteger loc = 1; 35 | // NSUInteger len = [attributes rangeOfString:@","].location - loc; 36 | // NSString *type = [attributes substringWithRange:NSMakeRange(loc, len)]; 37 | // NSLog(@"name:%s---attributes:%s",property_getName(property), 38 | // property_getAttributes(property)); 39 | // NSLog(@"name:%s---attributes:%s",((propertyStruct)property)->name,((propertyStruct)property)->attributes); 40 | // NSLog(@"%@",type); 41 | // 42 | // } 43 | for (int i = 0; i < outCount; i++) { 44 | objc_property_t property = properties[i]; 45 | HCDProperty *propertyObj = [HCDProperty propertyWithProperty:property]; 46 | [((NSMutableArray *)propertiesArray) addObject:propertyObj]; 47 | } 48 | 49 | return propertiesArray; 50 | } 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension2/HCDExtension/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #warning 博文参考地址:http://www.jianshu.com/p/d2ecef03f19e 10 | 11 | #import 12 | #import "HCDUser.h" 13 | #import "NSObject+Property.h" 14 | int main(int argc, const char * argv[]) { 15 | @autoreleasepool { 16 | 17 | NSArray *propertyArray = [HCDUser properties]; 18 | NSLog(@"%@",propertyArray); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension3/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension3/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/HCDPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPropertyType.h" 10 | #import "HCDExtensionConst.h" 11 | @implementation HCDPropertyType 12 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string{ 13 | return [[HCDPropertyType alloc] initWithTypeString:string]; 14 | } 15 | 16 | - (instancetype)initWithTypeString:(NSString *)string 17 | { 18 | if (self = [super init]) 19 | { 20 | NSUInteger loc = 1; 21 | NSUInteger len = [string rangeOfString:@","].location - loc; 22 | NSString *type = [string substringWithRange:NSMakeRange(loc, len)]; 23 | [self getTypeCode:type]; 24 | NSLog(@"%@",type); 25 | } 26 | return self; 27 | } 28 | /** 29 | * 得到具体的类型 30 | * 31 | * @param code 得到具体的类型信息 32 | */ 33 | - (void)getTypeCode:(NSString *)code 34 | { 35 | if ([code isEqualToString:MJPropertyTypeId]) { 36 | _idType = YES; 37 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 38 | // 去掉@"和",截取中间的类型名称 39 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 40 | _typeClass = NSClassFromString(_code); 41 | _numberType = (_typeClass == [NSNumber class] || [_typeClass isSubclassOfClass:[NSNumber class]]); 42 | } 43 | // 是否为数字类型 44 | NSString *lowerCode = code.lowercaseString; 45 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeChar]; 46 | //boole类型是number类型的一种。 47 | if ([numberTypes containsObject:lowerCode]) { 48 | _numberType = YES; 49 | 50 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 51 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 52 | _boolType = YES; 53 | } 54 | } 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDExtensionSource/NSObject+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Property.h" 10 | #import 11 | #import "HCDProperty.h" 12 | #import "HCDPropertyType.h" 13 | /** 14 | * 次结构体是一个属性列表的对象 15 | */ 16 | typedef struct property_t { 17 | const char *name; 18 | const char *attributes; 19 | } *propertyStruct; 20 | 21 | @implementation NSObject (Property) 22 | +(NSArray *)properties{ 23 | NSArray *propertiesArray = [NSMutableArray array]; 24 | //1 获取所有的属性 25 | unsigned int outCount = 0; 26 | objc_property_t *properties = class_copyPropertyList(self, &outCount); 27 | 28 | // for (int i = 0; i < outCount; i++) { 29 | // //去除一条属性 30 | // objc_property_t property = properties[i]; 31 | // //属性名 32 | // NSString *name = @(property_getName(property)); 33 | // //得到属性的各种信息 34 | // NSString *attributes = @(property_getAttributes(property)); 35 | // NSUInteger loc = 1; 36 | // NSUInteger len = [attributes rangeOfString:@","].location - loc; 37 | // NSString *type = [attributes substringWithRange:NSMakeRange(loc, len)]; 38 | // NSLog(@"name:%s---attributes:%s",property_getName(property), 39 | // property_getAttributes(property)); 40 | // NSLog(@"name:%s---attributes:%s",((propertyStruct)property)->name,((propertyStruct)property)->attributes); 41 | // NSLog(@"%@",type); 42 | // 43 | // } 44 | for (int i = 0; i < outCount; i++) { 45 | objc_property_t property = properties[i]; 46 | HCDProperty *propertyObj = [HCDProperty propertyWithProperty:property]; 47 | [((NSMutableArray *)propertiesArray) addObject:propertyObj]; 48 | NSLog(@"%@,%@",propertyObj.name,propertyObj.type.typeClass); 49 | } 50 | 51 | return propertiesArray; 52 | } 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension3/HCDExtension/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #warning 博文参考地址:http://www.jianshu.com/p/d2ecef03f19e 10 | 11 | #import 12 | #import "HCDUser.h" 13 | #import "NSObject+Property.h" 14 | int main(int argc, const char * argv[]) { 15 | @autoreleasepool { 16 | 17 | NSArray *propertyArray = [HCDUser properties]; 18 | NSLog(@"%@",propertyArray); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension4/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension4/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/HCDPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPropertyType.h" 10 | #import "HCDExtensionConst.h" 11 | @implementation HCDPropertyType 12 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string{ 13 | return [[HCDPropertyType alloc] initWithTypeString:string]; 14 | } 15 | 16 | - (instancetype)initWithTypeString:(NSString *)string 17 | { 18 | if (self = [super init]) 19 | { 20 | NSUInteger loc = 1; 21 | NSUInteger len = [string rangeOfString:@","].location - loc; 22 | NSString *type = [string substringWithRange:NSMakeRange(loc, len)]; 23 | [self getTypeCode:type]; 24 | // NSLog(@"%@",type); 25 | } 26 | return self; 27 | } 28 | /** 29 | * 得到具体的类型 30 | * 31 | * @param code 得到具体的类型信息 32 | */ 33 | - (void)getTypeCode:(NSString *)code 34 | { 35 | if ([code isEqualToString:MJPropertyTypeId]) { 36 | _idType = YES; 37 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 38 | // 去掉@"和",截取中间的类型名称 39 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 40 | _typeClass = NSClassFromString(_code); 41 | _numberType = (_typeClass == [NSNumber class] || [_typeClass isSubclassOfClass:[NSNumber class]]); 42 | } 43 | // 是否为数字类型 44 | NSString *lowerCode = code.lowercaseString; 45 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeChar]; 46 | //boole类型是number类型的一种。 47 | if ([numberTypes containsObject:lowerCode]) { 48 | _numberType = YES; 49 | 50 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 51 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 52 | _boolType = YES; 53 | } 54 | } 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/NSObject+HCDKeyValueObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKeyValueObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (HCDKeyValueObject) 12 | /** 13 | * 返回解析的实例对象 14 | * 15 | * @param keyValues 传入一个字典字典 16 | * 17 | * @return 返回一个解析好的实例对象 18 | */ 19 | + (instancetype)objectWithKeyValues:(id)keyValues; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDExtensionSource/NSObject+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Property.h" 10 | #import 11 | #import "HCDProperty.h" 12 | #import "HCDPropertyType.h" 13 | /** 14 | * 次结构体是一个属性列表的对象 15 | */ 16 | typedef struct property_t { 17 | const char *name; 18 | const char *attributes; 19 | } *propertyStruct; 20 | 21 | @implementation NSObject (Property) 22 | +(NSArray *)properties{ 23 | NSArray *propertiesArray = [NSMutableArray array]; 24 | //1 获取所有的属性 25 | unsigned int outCount = 0; 26 | objc_property_t *properties = class_copyPropertyList(self, &outCount); 27 | 28 | // for (int i = 0; i < outCount; i++) { 29 | // //去除一条属性 30 | // objc_property_t property = properties[i]; 31 | // //属性名 32 | // NSString *name = @(property_getName(property)); 33 | // //得到属性的各种信息 34 | // NSString *attributes = @(property_getAttributes(property)); 35 | // NSUInteger loc = 1; 36 | // NSUInteger len = [attributes rangeOfString:@","].location - loc; 37 | // NSString *type = [attributes substringWithRange:NSMakeRange(loc, len)]; 38 | // NSLog(@"name:%s---attributes:%s",property_getName(property), 39 | // property_getAttributes(property)); 40 | // NSLog(@"name:%s---attributes:%s",((propertyStruct)property)->name,((propertyStruct)property)->attributes); 41 | // NSLog(@"%@",type); 42 | // 43 | // } 44 | for (int i = 0; i < outCount; i++) { 45 | objc_property_t property = properties[i]; 46 | HCDProperty *propertyObj = [HCDProperty propertyWithProperty:property]; 47 | [((NSMutableArray *)propertiesArray) addObject:propertyObj]; 48 | //NSLog(@"%@,%@",propertyObj.name,propertyObj.type.typeClass); 49 | } 50 | 51 | return propertiesArray; 52 | } 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension4/HCDExtension/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #warning 博文参考地址:http://www.jianshu.com/p/d2ecef03f19e 10 | 11 | #import 12 | #import "HCDUser.h" 13 | #import "NSObject+Property.h" 14 | #import "NSObject+HCDKeyValueObject.h" 15 | int main(int argc, const char * argv[]) { 16 | @autoreleasepool { 17 | 18 | // NSDictionary *dict = @{ 19 | // @"name" : @"Jack", 20 | // @"icon" : @"lufy.png", 21 | // @"age" : @"20", 22 | // @"height" : @1.55, 23 | // @"money" : @"100.9", 24 | // @"sex" : @(SexFemale), 25 | // @"gay" : @"true", 26 | // }; 27 | // HCDUser *user = [HCDUser objectWithKeyValues:dict]; 28 | 29 | NSString *jsonString = @"{\"name\":\"Jack\", \"icon\":\"lufy.png\", \"age\":20}"; 30 | HCDUser *user = [HCDUser objectWithKeyValues:jsonString]; 31 | 32 | NSLog(@"name=%@, icon=%@, age=%zd, height=%@, money=%@, sex=%d, gay=%d", user.name, user.icon, user.age, user.height, user.money, user.sex, user.gay); 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension5/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension5/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/HCDPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPropertyType.h" 10 | #import "HCDExtensionConst.h" 11 | @implementation HCDPropertyType 12 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string{ 13 | return [[HCDPropertyType alloc] initWithTypeString:string]; 14 | } 15 | 16 | - (instancetype)initWithTypeString:(NSString *)string 17 | { 18 | if (self = [super init]) 19 | { 20 | NSUInteger loc = 1; 21 | NSUInteger len = [string rangeOfString:@","].location - loc; 22 | NSString *type = [string substringWithRange:NSMakeRange(loc, len)]; 23 | [self getTypeCode:type]; 24 | // NSLog(@"%@",type); 25 | } 26 | return self; 27 | } 28 | /** 29 | * 得到具体的类型 30 | * 31 | * @param code 得到具体的类型信息 32 | */ 33 | - (void)getTypeCode:(NSString *)code 34 | { 35 | if ([code isEqualToString:MJPropertyTypeId]) { 36 | _idType = YES; 37 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 38 | // 去掉@"和",截取中间的类型名称 39 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 40 | _typeClass = NSClassFromString(_code); 41 | _numberType = (_typeClass == [NSNumber class] || [_typeClass isSubclassOfClass:[NSNumber class]]); 42 | } 43 | // 是否为数字类型 44 | NSString *lowerCode = code.lowercaseString; 45 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeChar]; 46 | //boole类型是number类型的一种。 47 | if ([numberTypes containsObject:lowerCode]) { 48 | _numberType = YES; 49 | 50 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 51 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 52 | _boolType = YES; 53 | } 54 | } 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/NSObject+HCDKeyValueObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKeyValueObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (HCDKeyValueObject) 12 | /** 13 | * 返回解析的实例对象 14 | * 15 | * @param keyValues 传入一个字典字典 16 | * 17 | * @return 返回一个解析好的实例对象 18 | */ 19 | + (instancetype)objectWithKeyValues:(id)keyValues; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDExtensionSource/NSObject+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Property.h" 10 | #import 11 | #import "HCDProperty.h" 12 | #import "HCDPropertyType.h" 13 | /** 14 | * 次结构体是一个属性列表的对象 15 | */ 16 | typedef struct property_t { 17 | const char *name; 18 | const char *attributes; 19 | } *propertyStruct; 20 | 21 | @implementation NSObject (Property) 22 | +(NSArray *)properties{ 23 | NSArray *propertiesArray = [NSMutableArray array]; 24 | //1 获取所有的属性 25 | unsigned int outCount = 0; 26 | objc_property_t *properties = class_copyPropertyList(self, &outCount); 27 | 28 | // for (int i = 0; i < outCount; i++) { 29 | // //去除一条属性 30 | // objc_property_t property = properties[i]; 31 | // //属性名 32 | // NSString *name = @(property_getName(property)); 33 | // //得到属性的各种信息 34 | // NSString *attributes = @(property_getAttributes(property)); 35 | // NSUInteger loc = 1; 36 | // NSUInteger len = [attributes rangeOfString:@","].location - loc; 37 | // NSString *type = [attributes substringWithRange:NSMakeRange(loc, len)]; 38 | // NSLog(@"name:%s---attributes:%s",property_getName(property), 39 | // property_getAttributes(property)); 40 | // NSLog(@"name:%s---attributes:%s",((propertyStruct)property)->name,((propertyStruct)property)->attributes); 41 | // NSLog(@"%@",type); 42 | // 43 | // } 44 | for (int i = 0; i < outCount; i++) { 45 | objc_property_t property = properties[i]; 46 | HCDProperty *propertyObj = [HCDProperty propertyWithProperty:property]; 47 | [((NSMutableArray *)propertiesArray) addObject:propertyObj]; 48 | //NSLog(@"%@,%@",propertyObj.name,propertyObj.type.typeClass); 49 | } 50 | 51 | return propertiesArray; 52 | } 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension5/HCDExtension/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #warning 博文参考地址:http://www.jianshu.com/p/d2ecef03f19e 10 | 11 | #import 12 | #import "HCDUser.h" 13 | #import "NSObject+Property.h" 14 | #import "NSObject+HCDKeyValueObject.h" 15 | int main(int argc, const char * argv[]) { 16 | @autoreleasepool { 17 | 18 | // NSDictionary *dict = @{ 19 | // @"name" : @"Jack", 20 | // @"icon" : @"lufy.png", 21 | // @"age" : @"20", 22 | // @"height" : @1.55, 23 | // @"money" : @"100.9", 24 | // @"sex" : @(SexFemale), 25 | // @"gay" : @"true", 26 | // }; 27 | // HCDUser *user = [HCDUser objectWithKeyValues:dict]; 28 | 29 | NSString *jsonString = @"{\"name\":\"Jack\", \"icon\":\"lufy.png\", \"age\":20}"; 30 | HCDUser *user = [HCDUser objectWithKeyValues:jsonString]; 31 | 32 | NSLog(@"name=%@, icon=%@, age=%zd, height=%@, money=%@, sex=%d, gay=%d", user.name, user.icon, user.age, user.height, user.money, user.sex, user.gay); 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension6/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension6/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/HCDPropertyType.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDPropertyType.h" 10 | #import "HCDExtensionConst.h" 11 | #import "HCDProperty.h" 12 | #import "NSObject+Property.h" 13 | @implementation HCDPropertyType 14 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string{ 15 | return [[HCDPropertyType alloc] initWithTypeString:string]; 16 | } 17 | 18 | - (instancetype)initWithTypeString:(NSString *)string 19 | { 20 | if (self = [super init]) 21 | { 22 | NSUInteger loc = 1; 23 | NSUInteger len = [string rangeOfString:@","].location - loc; 24 | NSString *type = [string substringWithRange:NSMakeRange(loc, len)]; 25 | [self getTypeCode:type]; 26 | // NSLog(@"%@",type); 27 | } 28 | return self; 29 | } 30 | /** 31 | * 得到具体的类型 32 | * 33 | * @param code 得到具体的类型信息 34 | */ 35 | - (void)getTypeCode:(NSString *)code 36 | { 37 | if ([code isEqualToString:MJPropertyTypeId]) { 38 | _idType = YES; 39 | } else if (code.length > 3 && [code hasPrefix:@"@\""]) { 40 | // 去掉@"和",截取中间的类型名称 41 | _code = [code substringWithRange:NSMakeRange(2, code.length - 3)]; 42 | _typeClass = NSClassFromString(_code); 43 | _numberType = (_typeClass == [NSNumber class] || [_typeClass isSubclassOfClass:[NSNumber class]]); 44 | // 45 | _fromFoundation = [NSObject isClassFromFoundation:_typeClass]; 46 | } 47 | // 是否为数字类型 48 | NSString *lowerCode = code.lowercaseString; 49 | NSArray *numberTypes = @[MJPropertyTypeInt, MJPropertyTypeShort, MJPropertyTypeBOOL1, MJPropertyTypeBOOL2, MJPropertyTypeFloat, MJPropertyTypeDouble, MJPropertyTypeLong, MJPropertyTypeChar]; 50 | //boole类型是number类型的一种。 51 | if ([numberTypes containsObject:lowerCode]) { 52 | _numberType = YES; 53 | 54 | if ([lowerCode isEqualToString:MJPropertyTypeBOOL1] 55 | || [lowerCode isEqualToString:MJPropertyTypeBOOL2]) { 56 | _boolType = YES; 57 | } 58 | } 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/NSObject+HCDKeyValueObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKeyValueObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (HCDKeyValueObject) 12 | /** 13 | * 返回解析的实例对象 14 | * 15 | * @param keyValues 传入一个字典字典 16 | * 17 | * @return 返回一个解析好的实例对象 18 | */ 19 | + (instancetype)objectWithKeyValues:(id)keyValues; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | /** 19 | * 判断是否是foundation框架的类 20 | * 21 | * @param c 类名字 22 | * 23 | * @return 返回布尔值 24 | */ 25 | + (BOOL)isClassFromFoundation:(Class) c; 26 | @end 27 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDUser; 11 | @interface HCDStatus : NSObject 12 | /** 微博文本内容 */ 13 | @property (copy, nonatomic) NSString *text; 14 | /** 微博作者 */ 15 | @property (strong, nonatomic) HCDUser *user; 16 | /** 转发的微博 */ 17 | @property (strong, nonatomic) HCDStatus *retweetedHCDStatus; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDStatus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDStatus.h" 10 | 11 | @implementation HCDStatus 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension6/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension7/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension7/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/Ad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Ad.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Ad : NSObject 12 | /** 广告图片 */ 13 | @property (copy, nonatomic) NSString *image; 14 | /** 广告url */ 15 | @property (strong, nonatomic) NSURL *url; 16 | @end 17 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/Ad.m: -------------------------------------------------------------------------------- 1 | // 2 | // Ad.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Ad.h" 10 | 11 | @implementation Ad 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/BaseObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseObject : NSObject 12 | @property (copy, nonatomic) NSString *name; 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/BaseObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | @implementation BaseObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/NSObject+HCDKeyValueObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKeyValueObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDKeyValue 12 | @optional 13 | /** 14 | * 用于指定一个数组中元素的类型 15 | * 16 | * @return 返回一个字典,值表示对应的类型 17 | */ 18 | + (NSDictionary *) objectClassInArray; 19 | /** 20 | * 把一些属性值替换为指定的Key 21 | * 22 | * @return 返回一个对应的字典 23 | */ 24 | //+ (NSDictionary *)replacedKeyFromPropertyName; 25 | 26 | @end 27 | 28 | @interface NSObject (HCDKeyValueObject) 29 | /** 30 | * 返回解析的实例对象 31 | * 32 | * @param keyValues 传入一个字典字典 33 | * 34 | * @return 返回一个解析好的实例对象 35 | */ 36 | + (instancetype)objectWithKeyValues:(id)keyValues; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | /** 19 | * 判断是否是foundation框架的类 20 | * 21 | * @param c 类名字 22 | * 23 | * @return 返回布尔值 24 | */ 25 | + (BOOL)isClassFromFoundation:(Class) c; 26 | @end 27 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDUser; 11 | @interface HCDStatus : NSObject 12 | /** 微博文本内容 */ 13 | @property (copy, nonatomic) NSString *text; 14 | /** 微博作者 */ 15 | @property (strong, nonatomic) HCDUser *user; 16 | /** 转发的微博 */ 17 | @property (strong, nonatomic) HCDStatus *retweetedHCDStatus; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDStatus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDStatus.h" 10 | 11 | @implementation HCDStatus 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | 11 | @implementation HCDUser 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/IDAndDescription.h: -------------------------------------------------------------------------------- 1 | // 2 | // IDAndDescription.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface IDAndDescription : NSObject 12 | @property (nonatomic, copy) NSString *ID; 13 | @property (nonatomic, copy) NSString *Description; 14 | @end 15 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/IDAndDescription.m: -------------------------------------------------------------------------------- 1 | // 2 | // IDAndDescription.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "IDAndDescription.h" 10 | 11 | @implementation IDAndDescription 12 | //+ (NSDictionary *)replacedKeyFromPropertyName{ 13 | // return @{ 14 | // @"ID" : @"id", 15 | // @"Description" : @"description" 16 | // }; 17 | //} 18 | // 19 | @end 20 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/Status.h: -------------------------------------------------------------------------------- 1 | // 2 | // Status.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDUser; 11 | @interface Status : NSObject 12 | /** 微博文本内容 */ 13 | @property (copy, nonatomic) NSString *text; 14 | /** 微博作者 */ 15 | @property (strong, nonatomic) HCDUser *user; 16 | /** 转发的微博 */ 17 | @property (strong, nonatomic) Status *retweetedStatus; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/Status.m: -------------------------------------------------------------------------------- 1 | // 2 | // Status.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Status.h" 10 | 11 | @implementation Status 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/StatusResult.h: -------------------------------------------------------------------------------- 1 | // 2 | // StatusResult.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | @interface StatusResult : BaseObject 12 | /** 存放着某一页微博数据(里面都是Status模型) */ 13 | @property (strong, nonatomic) NSMutableArray *statuses; 14 | /** 存放着一堆的广告数据(里面都是Ad模型) */ 15 | @property (strong, nonatomic) NSArray *ads; 16 | /** 总数 */ 17 | @property (strong, nonatomic) NSNumber *totalNumber; 18 | /** 上一页的游标 */ 19 | @property (assign, nonatomic) long long previousCursor; 20 | /** 下一页的游标 */ 21 | @property (assign, nonatomic) long long nextCursor; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension7/HCDExtension/StatusResult.m: -------------------------------------------------------------------------------- 1 | // 2 | // StatusResult.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "StatusResult.h" 10 | 11 | @implementation StatusResult 12 | /** 13 | * 用于指定array中的对象类型 14 | * 15 | * @return 返回一个字典。值是对应的类型 16 | */ 17 | + (NSDictionary *)objectClassInArray 18 | { 19 | return @{ 20 | @"statuses" : @"Status", 21 | @"ads" : @"Ad" 22 | }; 23 | } 24 | @end 25 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/.LSOverride: -------------------------------------------------------------------------------- 1 | /Applications/Xcode.app -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/project.xcworkspace/xcshareddata/HCDExtension.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 98CA2E7C-8582-4CF2-A3C1-82EC14D2ABAE 9 | IDESourceControlProjectName 10 | HCDExtension 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice 15 | 16 | IDESourceControlProjectPath 17 | HCDExtension8/HCDExtension.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/HCDExtension8/HCDExtension.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | HCDExtension.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4D8B3CFF1BAE7A4D00360969 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/Ad.h: -------------------------------------------------------------------------------- 1 | // 2 | // Ad.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Ad : NSObject 12 | /** 广告图片 */ 13 | @property (copy, nonatomic) NSString *image; 14 | /** 广告url */ 15 | @property (strong, nonatomic) NSURL *url; 16 | @end 17 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/Ad.m: -------------------------------------------------------------------------------- 1 | // 2 | // Ad.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Ad.h" 10 | 11 | @implementation Ad 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/BaseObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseObject : NSObject 12 | @property (copy, nonatomic) NSString *name; 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/BaseObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseObject.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | @implementation BaseObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/HCDExtensionConst.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 所有能处理的类型 12 | */ 13 | extern NSString *const MJPropertyTypeInt; 14 | extern NSString *const MJPropertyTypeShort; 15 | extern NSString *const MJPropertyTypeFloat; 16 | extern NSString *const MJPropertyTypeDouble; 17 | extern NSString *const MJPropertyTypeLong; 18 | extern NSString *const MJPropertyTypeLongLong; 19 | extern NSString *const MJPropertyTypeChar; 20 | extern NSString *const MJPropertyTypeBOOL1; 21 | extern NSString *const MJPropertyTypeBOOL2; 22 | extern NSString *const MJPropertyTypePointer; 23 | 24 | extern NSString *const MJPropertyTypeIvar; 25 | extern NSString *const MJPropertyTypeMethod; 26 | extern NSString *const MJPropertyTypeBlock; 27 | extern NSString *const MJPropertyTypeClass; 28 | extern NSString *const MJPropertyTypeSEL; 29 | extern NSString *const MJPropertyTypeId; -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/HCDExtensionConst.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDExtensionConst.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDExtensionConst.h" 10 | 11 | NSString *const MJPropertyTypeInt = @"i"; 12 | NSString *const MJPropertyTypeShort = @"s"; 13 | NSString *const MJPropertyTypeFloat = @"f"; 14 | NSString *const MJPropertyTypeDouble = @"d"; 15 | NSString *const MJPropertyTypeLong = @"q"; 16 | NSString *const MJPropertyTypeChar = @"c"; 17 | NSString *const MJPropertyTypeBOOL1 = @"c"; 18 | NSString *const MJPropertyTypeBOOL2 = @"b"; 19 | NSString *const MJPropertyTypePointer = @"*"; 20 | 21 | NSString *const MJPropertyTypeIvar = @"^{objc_ivar=}"; 22 | NSString *const MJPropertyTypeMethod = @"^{objc_method=}"; 23 | NSString *const MJPropertyTypeBlock = @"@?"; 24 | NSString *const MJPropertyTypeClass = @"#"; 25 | NSString *const MJPropertyTypeSEL = @":"; 26 | NSString *const MJPropertyTypeId = @"@"; -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/HCDProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class HCDPropertyType; 13 | /** 14 | * 这个类包含两个属性、一个是属性的名字、一个是属性的类型信息 15 | */ 16 | @interface HCDProperty : NSObject 17 | /** 成员属性的名字 */ 18 | @property (nonatomic, readonly) NSString *name; 19 | /** 成员属性的类型 */ 20 | @property (nonatomic, readonly) HCDPropertyType *type; 21 | + (instancetype)propertyWithProperty:(objc_property_t)property; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/HCDProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDProperty.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDProperty.h" 10 | #import "HCDPropertyType.h" 11 | @implementation HCDProperty 12 | /** 13 | * 初始化一个对象 14 | * 15 | * @param property 类型信息 16 | * 17 | * @return 返回自定义的类型信息 18 | */ 19 | + (instancetype)propertyWithProperty:(objc_property_t)property{ 20 | return [[HCDProperty alloc] initWithProperty:property]; 21 | } 22 | 23 | 24 | - (instancetype)initWithProperty:(objc_property_t)property{ 25 | if (self = [super init]) { 26 | _name = @(property_getName(property)); 27 | 28 | _type = [HCDPropertyType propertyTypeWithAttributeString:@(property_getAttributes(property))];; 29 | } 30 | return self; 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/HCDPropertyType.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDPropertyType.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDPropertyType : NSObject 12 | /** 类型标识符 */ 13 | @property (nonatomic, copy) NSString *code; 14 | 15 | /** 是否为id类型 */ 16 | @property (nonatomic, readonly, getter=isIdType) BOOL idType; 17 | 18 | /** 是否为基本数字类型:int、float等 */ 19 | @property (nonatomic, readonly, getter=isNumberType) BOOL numberType; 20 | 21 | /** 是否为BOOL类型 */ 22 | @property (nonatomic, readonly, getter=isBoolType) BOOL boolType; 23 | 24 | /** 对象类型(如果是基本数据类型,此值为nil) */ 25 | @property (nonatomic, readonly) Class typeClass; 26 | 27 | /** 类型是否来自于Foundation框架,比如NSString、NSArray */ 28 | @property (nonatomic, readonly, getter = isFromFoundation) BOOL fromFoundation; 29 | 30 | 31 | + (instancetype)propertyTypeWithAttributeString:(NSString *)string; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/NSObject+HCDKeyValueObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKeyValueObject.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol HCDKeyValue 12 | @optional 13 | /** 14 | * 用于指定一个数组中元素的类型 15 | * 16 | * @return 返回一个字典,值表示对应的类型 17 | */ 18 | + (NSDictionary *) objectClassInArray; 19 | /** 20 | * 实际开发中,服务器通常返回一个字段名为id,或者description的JSON数据,而这两个名字在OC中有特殊含义,如上所示,在定义属性的时候并不能使用这类名称.这时属性名与字典key不再是直接对应的关系,需要加入一层转换. 21 | * 22 | * @return 返回一个对应的字典 23 | */ 24 | + (NSDictionary *)replacedKeyFromPropertyName; 25 | 26 | @end 27 | 28 | @interface NSObject (HCDKeyValueObject) 29 | /** 30 | * 返回解析的实例对象 31 | * 32 | * @param keyValues 传入一个字典字典 33 | * 34 | * @return 返回一个解析好的实例对象 35 | */ 36 | + (instancetype)objectWithKeyValues:(id)keyValues; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDExtensionSource/NSObject+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Property.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (Property) 12 | /** 13 | * 这个方法返回对象包含的属性列表。列表中的每个对象包含名字和类型信息 14 | * 15 | * @return 属性列表 16 | */ 17 | + (NSArray *)properties; 18 | /** 19 | * 判断是否是foundation框架的类 20 | * 21 | * @param c 类名字 22 | * 23 | * @return 返回布尔值 24 | */ 25 | + (BOOL)isClassFromFoundation:(Class) c; 26 | @end 27 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class HCDUser; 11 | @interface HCDStatus : NSObject 12 | /** 微博文本内容 */ 13 | @property (copy, nonatomic) NSString *text; 14 | /** 微博作者 */ 15 | @property (strong, nonatomic) HCDUser *user; 16 | /** 转发的微博 */ 17 | @property (strong, nonatomic) HCDStatus *retweetedHCDStatus; 18 | @end 19 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDStatus.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDStatus.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDStatus.h" 10 | 11 | @implementation HCDStatus 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef enum { 11 | SexMale, 12 | SexFemale 13 | } Sex; 14 | 15 | @interface HCDUser : NSObject 16 | /** 名称 */ 17 | @property (copy, nonatomic) NSString *name; 18 | /** 头像 */ 19 | @property (copy, nonatomic) NSString *icon; 20 | /** 年龄 */ 21 | @property (assign, nonatomic) unsigned int age; 22 | /** 身高 */ 23 | @property (copy, nonatomic) NSString *height; 24 | /** 财富 */ 25 | @property (strong, nonatomic) NSNumber *money; 26 | /** 性别 */ 27 | @property (assign, nonatomic) Sex sex; 28 | /** 同性恋 */ 29 | @property (assign, nonatomic, getter=isGay) BOOL gay; 30 | 31 | @property (nonatomic, strong) id test; 32 | @end 33 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/HCDUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDUser.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDUser.h" 10 | @interface HCDUser () 11 | 12 | @end 13 | @implementation HCDUser 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/IDAndDescription.h: -------------------------------------------------------------------------------- 1 | // 2 | // IDAndDescription.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 这个类主要用于演示key的替换 12 | */ 13 | @interface IDAndDescription : NSObject 14 | @property (nonatomic, copy) NSString *ID; 15 | @property (nonatomic, copy) NSString *Description; 16 | @end 17 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/IDAndDescription.m: -------------------------------------------------------------------------------- 1 | // 2 | // IDAndDescription.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "IDAndDescription.h" 10 | 11 | @implementation IDAndDescription 12 | 13 | 14 | /** 15 | * 实际开发中,服务器通常返回一个字段名为id,或者description的JSON数据,而这两个名字在OC中有特殊含义,如上所示,在定义属性的时候并不能使用这类名称.这时属性名与字典key不再是直接对应的关系,需要加入一层转换. 16 | 17 | 源码中key的替换也有几种方式选择,这里实现replacedKeyFromPropertyName这一方式. 18 | 19 | 过程是在要替换key的模型类中实现replacedKeyFromPropertyName方法,返回一个原始key和更名的key对应的字典.replacedKeyFromPropertyName在protocol中声明 20 | * 21 | * @return 22 | */ 23 | + (NSDictionary *)replacedKeyFromPropertyName{ 24 | return @{ 25 | @"ID" : @"id",//把服务器返回的id属性替换为ID类型 26 | @"Description" : @"description" 27 | }; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/Status.h: -------------------------------------------------------------------------------- 1 | // 2 | // Status.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class User; 11 | @interface Status : NSObject 12 | /** 微博文本内容 */ 13 | @property (copy, nonatomic) NSString *text; 14 | /** 微博作者 */ 15 | @property (strong, nonatomic) User *user; 16 | /** 转发的微博 */ 17 | @property (strong, nonatomic) Status *retweetedStatus; 18 | 19 | @property (nonatomic, copy) NSString *test; 20 | @end 21 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/Status.m: -------------------------------------------------------------------------------- 1 | // 2 | // Status.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "Status.h" 10 | 11 | @implementation Status 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/StatusResult.h: -------------------------------------------------------------------------------- 1 | // 2 | // StatusResult.h 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "BaseObject.h" 10 | 11 | @interface StatusResult : BaseObject 12 | /** 存放着某一页微博数据(里面都是Status模型) */ 13 | @property (strong, nonatomic) NSMutableArray *statuses; 14 | /** 存放着一堆的广告数据(里面都是Ad模型) */ 15 | @property (strong, nonatomic) NSArray *ads; 16 | /** 总数 */ 17 | @property (strong, nonatomic) NSNumber *totalNumber; 18 | /** 上一页的游标 */ 19 | @property (assign, nonatomic) long long previousCursor; 20 | /** 下一页的游标 */ 21 | @property (assign, nonatomic) long long nextCursor; 22 | @end 23 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/StatusResult.m: -------------------------------------------------------------------------------- 1 | // 2 | // StatusResult.m 3 | // HCDExtension 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "StatusResult.h" 10 | 11 | @implementation StatusResult 12 | /** 13 | * 用于指定array中的对象类型 14 | * 15 | * @return 返回一个字典。值是对应的类型 16 | */ 17 | + (NSDictionary *)objectClassInArray 18 | { 19 | return @{ 20 | @"statuses" : @"Status",//statuses数组里面的类型是Status 21 | @"ads" : @"Ad" 22 | }; 23 | } 24 | @end 25 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/User.h: -------------------------------------------------------------------------------- 1 | // 2 | // User.h 3 | // 字典转模型 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "HCDUser.h" 11 | //typedef enum { 12 | // SexMale, 13 | // SexFemale 14 | //} Sex; 15 | 16 | @interface User : NSObject 17 | 18 | /** 名称 */ 19 | @property (copy, nonatomic) NSString *name; 20 | /** 头像 */ 21 | @property (copy, nonatomic) NSString *icon; 22 | /** 年龄 */ 23 | @property (assign, nonatomic) unsigned int age; 24 | /** 身高 */ 25 | @property (copy, nonatomic) NSString *height; 26 | /** 财富 */ 27 | @property (strong, nonatomic) NSNumber *money; 28 | /** 性别 */ 29 | @property (assign, nonatomic) Sex sex; 30 | /** 同性恋 */ 31 | @property (assign, nonatomic, getter=isGay) BOOL gay; 32 | 33 | @property (nonatomic, copy) NSString *test; 34 | 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /HCDExtension8/HCDExtension/User.m: -------------------------------------------------------------------------------- 1 | // 2 | // User.m 3 | // 字典转模型 4 | // 5 | // Created by 黄成都 on 15/9/20. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "User.h" 10 | 11 | @interface User () 12 | 13 | @end 14 | 15 | @implementation User 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/IMP指针的作用/IMP指针的作用.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | IMP指针的作用.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD12CDA21BBA37F60054D410 16 | 17 | primary 18 | 19 | 20 | DD12CDBB1BBA37F60054D410 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/UIViewController+IMPCategory.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+IMPCategory.h 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIViewController (IMPCategory) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/UIViewController+IMPCategory.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+IMPCategory.m 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+IMPCategory.h" 10 | #import "objc/runtime.h" 11 | 12 | typedef void (*_VIMP)(id,SEL, ...);//返回类型为空 13 | typedef id (*_IMP)(id,SEL, ...);//有返回类型 14 | 15 | @implementation UIViewController (IMPCategory) 16 | //====================第一种实现================ 17 | //+(void)load{ 18 | // //保证交换方法只执行一次 19 | // static dispatch_once_t onceToken; 20 | // dispatch_once(&onceToken, ^{ 21 | // //获取到这个累得viewDidLoad方法,他的类型是一个objc_method结构体指针 22 | // Method viewDidLoad = class_getInstanceMethod(self, @selector(viewDidLoad)); 23 | // //获取自己刚刚新建的一个方法 24 | // Method viewDidLoaded = class_getInstanceMethod(self, @selector(viewDidLoaded)); 25 | // //交换两个方法的实现 26 | // method_exchangeImplementations(viewDidLoad, viewDidLoaded); 27 | // }); 28 | //} 29 | // 30 | ////新建一个方法与ViewDidLoad交换实现 31 | //-(void)viewDidLoaded{ 32 | // //调用系统原有的方法 33 | // [self viewDidLoaded]; 34 | // NSLog(@"%@ did load",self); 35 | //} 36 | //========================第二种实现=============================== 37 | +(void)load{ 38 | //保证交换方法只执行一次 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | //获取到这个累得viewDidLoad方法,他的类型是一个objc_method结构体指针 42 | Method viewDidLoad = class_getInstanceMethod(self, @selector(viewDidLoad)); 43 | //获取方法实现,因为我们要实现的viewDidLoad方法是返回为void的类型。所以我们需要用_VIMP 44 | _VIMP viewDidLaod_IMP = (_VIMP)method_getImplementation(viewDidLoad); 45 | //重新设置实现 46 | method_setImplementation(viewDidLoad, imp_implementationWithBlock(^(id target, SEL action){ 47 | viewDidLaod_IMP(target,@selector(viewDidLoad)); 48 | //新增代码 49 | NSLog(@"%@ did load",target); 50 | })); 51 | }); 52 | 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "UIViewController+IMPCategory.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // IMP指针的作用 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用Tests/IMP_____Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // IMP_____Tests.m 3 | // IMP指针的作用Tests 4 | // 5 | // Created by yifan on 15/9/29. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface IMP_____Tests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation IMP_____Tests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /IMP指针的作用/IMP指针的作用Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj/project.xcworkspace/xcshareddata/NSArraySwizzing.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 24173D9E-2884-41EA-85EB-B1A605AB5886 9 | IDESourceControlProjectName 10 | NSArraySwizzing 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice.git 15 | 16 | IDESourceControlProjectPath 17 | OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NSArraySwizzing.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DDC58B311B86BD38005D6BC5 16 | 17 | primary 18 | 19 | 20 | DDC58B4A1B86BD38005D6BC5 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/NSArray+Swizzle.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+Swizzle.h 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (Swizzle) 12 | -(id)myLastObject; 13 | @end 14 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/NSArray+Swizzle.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+Swizzle.m 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSArray+Swizzle.h" 10 | 11 | @implementation NSArray (Swizzle) 12 | -(id)myLastObject{ 13 | //[self myLastObject] 将会执行真的 [self lastObject] 14 | id ret = [self myLastObject]; 15 | NSLog(@"**********myLastObject************"); 16 | return ret; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NSArray+Swizzle.h" 11 | #import 12 | 13 | #warning http://blog.csdn.net/yiyaaixuexi/article/details/9374411 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | Method ori_Method = class_getInstanceMethod([NSArray class], @selector(lastObject)); 23 | Method my_Method = class_getInstanceMethod([NSArray class], @selector(myLastObject)); 24 | //修改者两个方法的实现 25 | method_exchangeImplementations(ori_Method, my_Method); 26 | NSArray *array = @[@"0",@"1",@"2",@"3"]; 27 | NSString *string = [array lastObject]; 28 | NSLog(@"TEST RESULT : %@",string); 29 | } 30 | 31 | - (void)didReceiveMemoryWarning { 32 | [super didReceiveMemoryWarning]; 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzing/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // NSArraySwizzing 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzingTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /OC消息转发实践/NSArraySwizzing/NSArraySwizzingTests/NSArraySwizzingTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArraySwizzingTests.m 3 | // NSArraySwizzingTests 4 | // 5 | // Created by yifan on 15/8/21. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface NSArraySwizzingTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation NSArraySwizzingTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/xcshareddata/OC消息转发.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | A9531DAA-D99A-4F2E-B583-82A970457320 9 | IDESourceControlProjectName 10 | OC消息转发 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice.git 15 | 16 | IDESourceControlProjectPath 17 | OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OC消息转发.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DDCA84B81B75EAB300F162A6 16 | 17 | primary 18 | 19 | 20 | DDCA84D11B75EAB300F162A6 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OC消息转发.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DDCA84B81B75EAB300F162A6 16 | 17 | primary 18 | 19 | 20 | DDCA84D11B75EAB300F162A6 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/UIViewController+HCDMethodSwizzling.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HCDMethodSwizzling.h 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIViewController (HCDMethodSwizzling) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/UIViewController+HCDMethodSwizzling.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+HCDMethodSwizzling.m 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+HCDMethodSwizzling.h" 10 | #import 11 | @implementation UIViewController (HCDMethodSwizzling) 12 | +(void)load{ 13 | static dispatch_once_t onceToken; 14 | dispatch_once(&onceToken, ^{ 15 | Class class = [self class]; 16 | 17 | SEL originalSelector = @selector(viewWillAppear:); 18 | SEL swizzledSelector = @selector(mrc_viewWillAppear:); 19 | 20 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 21 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 22 | 23 | BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); 24 | if (success) { 25 | class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); 26 | } else { 27 | method_exchangeImplementations(originalMethod, swizzledMethod); 28 | } 29 | }); 30 | } 31 | 32 | #pragma mark - Method Swizzling 33 | 34 | - (void)mrc_viewWillAppear:(BOOL)animated { 35 | //[self mrc_viewWillAppear:animated]; 36 | //NSLog(@"消息转发实现"); 37 | 38 | NSLog(@"类%@",NSStringFromClass([self class])); 39 | } 40 | 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | // Do any additional setup after loading the view, typically from a nib. 21 | } 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OC消息转发 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /OC消息转发实践/UIViewControllerSwizzing/OC消息转发Tests/OC____Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // OC____Tests.m 3 | // OC消息转发Tests 4 | // 5 | // Created by yifan on 15/8/8. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface OC____Tests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation OC____Tests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/project.xcworkspace/xcshareddata/Objective-C Runtime原理.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | BEDD799D-079A-4675-B9E7-9A37E66183F7 9 | IDESourceControlProjectName 10 | project 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice.git 15 | 16 | IDESourceControlProjectPath 17 | Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Objective-C Runtime原理.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DDF8476F1B9FC08C00EB6E53 16 | 17 | primary 18 | 19 | 20 | DDF847881B9FC08C00EB6E53 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Objective-C Runtime原理 4 | // 5 | // Created by yifan on 15/9/9. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Objective-C Runtime原理 4 | // 5 | // Created by yifan on 15/9/9. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Objective-C Runtime原理 4 | // 5 | // Created by yifan on 15/9/9. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Objective-C Runtime原理 4 | // 5 | // Created by yifan on 15/9/9. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Objective-C Runtime原理/Objective-C Runtime原理Tests/Objective_C_Runtime__Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Objective_C_Runtime__Tests.m 3 | // Objective-C Runtime原理Tests 4 | // 5 | // Created by yifan on 15/9/9. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface Objective_C_Runtime__Tests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation Objective_C_Runtime__Tests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Objective-C消息发送和消息转发机制的实现.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD1F30241BACE989005735F8 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/CompanyModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // CompanyModel.h 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | * 这个类的作用主要用于实现PersonModel没有实现的方法,用于接收消息转发 12 | */ 13 | @interface CompanyModel : NSObject 14 | 15 | - (NSString *)companyName; 16 | 17 | - (NSString *)deptName:(BOOL)isWithCompanyName; 18 | @end 19 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/CompanyModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // CompanyModel.m 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "CompanyModel.h" 10 | 11 | @implementation CompanyModel 12 | - (NSString *)companyName{ 13 | 14 | return @"测试公司"; 15 | } 16 | 17 | - (NSString *)deptName:(BOOL)isWithCompanyName{ 18 | if (isWithCompanyName) { 19 | return @"测试公司研发部门"; 20 | }else{ 21 | return @"研发部门"; 22 | } 23 | } 24 | @end 25 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/PersonModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // PersonModel.h 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | @class CompanyModel; 11 | @interface PersonModel : NSObject 12 | @property(nonatomic, copy)NSString *firstName; 13 | @property(nonatomic, copy)NSString *lastName; 14 | //这个属性在实现文件里面设置为动态属性、所以并不会生成get和set方法 15 | @property(nonatomic, copy)NSString *name; 16 | //这两个方法根本就没有实现 17 | - (NSString *)companyName; 18 | - (NSString *)deptName; 19 | @end 20 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "PersonModel.h" 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | PersonModel *personModel = [[PersonModel alloc] init]; 20 | 21 | // //消息转发 resolveInstanceMethod 22 | personModel.name = @"Jim Green"; 23 | NSString *name = personModel.name; 24 | NSLog(@"%@", name); 25 | //消息转发 forwardingTargetForSelector 26 | NSString *name1 = [personModel companyName]; 27 | NSLog(@"%@", name1); 28 | // //消息转发 forwardInvocation 29 | NSString *name2 = [personModel deptName]; 30 | NSLog(@"%@", name2); 31 | 32 | } 33 | 34 | - (void)didReceiveMemoryWarning { 35 | [super didReceiveMemoryWarning]; 36 | // Dispose of any resources that can be recreated. 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Objective-C消息发送和消息转发机制的实现/Objective-C消息发送和消息转发机制的实现/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Objective-C消息发送和消息转发机制的实现 4 | // 5 | // Created by yifan on 15/9/19. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## 下面的链接地址是我在学习过程中找到关于运行时的相关文章的干货集合。 3 | 4 | [自己动手实现 KVO(Demo还没有完成)](http://tech.glowing.com/cn/implement-kvo/)
5 | [轻松学习之三——IMP指针的作用](http://www.jianshu.com/p/425a39d43d16)
6 | [轻松学习之一--Objective-C消息转发](http://www.jianshu.com/p/1bde36ad9938)
7 | [iOS~runtime理解](http://www.jianshu.com/p/927c8384855a)
8 | [OC消息转发实践](http://blog.csdn.net/yiyaaixuexi/article/details/9374411)
9 | [Objective-C Runtime原理(主要讲原理)](http://tech.glowing.com/cn/objective-c-runtime/)
10 | [Objective-C Runtime原理(主要讲实践)](http://tech.glowing.com/cn/method-swizzling-aop/)
11 | [【OC刨根问底】-Runtime简单粗暴理解](http://www.jianshu.com/p/f900de4a1495)
12 | [【iOS程序启动与运转】- RunLoop个人小结](http://www.cocoachina.com/ios/20150821/13119.html)
13 | [伯乐在线RunTime的文章1](http://blog.jobbole.com/79545/)
14 | [伯乐在线RunTime的文章2](http://blog.jobbole.com/79566/)
15 | [伯乐在线RunTime的文章3](http://blog.jobbole.com/79570/)
16 | [深入理解Objective-C的Runtime机制](http://www.csdn.net/article/2015-07-06/2825133-objective-c-runtime)
17 | [深入理解RunLoop](http://blog.ibireme.com/2015/05/18/runloop/)
18 | ##很好
19 | [刨根问底Objective-C Runtime(1)- Self & Super](http://chun.tips/2014/11/05/objc-runtime-1/)
20 | [刨根问底 Objective-C Runtime(2)- Object & Class & Meta Class](http://chun.tips/2014/11/05/objc-runtime-2/)
21 | [刨根问底 Objective-C Runtime(3)- 消息 和 Category](http://chun.tips/2014/11/06/objc-runtime-3/)
22 | [http://chun.tips/2014/11/06/objc-runtime-4/](http://chun.tips/2014/11/06/objc-runtime-4/)
23 | [Objective-C之run loop详解]( http://blog.csdn.net/wzzvictory/article/details/9237973)
24 | [跟着MJExtension实现简单的字典转模型框架](http://www.jianshu.com/p/d2ecef03f19e)
25 | [基于runloop的线程保活、销毁与通信](http://www.jianshu.com/p/4d5b6fc33519)
26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/xcshareddata/iOS~runtime理解.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | BCD52040-FD41-445E-8CBD-949C6AAFC047 9 | IDESourceControlProjectName 10 | iOS~runtime理解 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4401B2307F13388936EBACB75255EB252141C7F3 14 | https://github.com/huang303513/iOS-RunTime-Practice.git 15 | 16 | IDESourceControlProjectPath 17 | iOS~runtime理解/iOS~runtime理解.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4401B2307F13388936EBACB75255EB252141C7F3 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/huang303513/iOS-RunTime-Practice.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 4401B2307F13388936EBACB75255EB252141C7F3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4401B2307F13388936EBACB75255EB252141C7F3 36 | IDESourceControlWCCName 37 | iOS-RunTime-Practice 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/xcuserdata/huangchengdu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/iOS~runtime理解/iOS~runtime理解.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/xcuserdata/huangchengdu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iOS~runtime理解.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DB834E21B990F1900B40DD9 16 | 17 | primary 18 | 19 | 20 | 4DB834FB1B990F1900B40DD9 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | iOS~runtime理解.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4DB834E21B990F1900B40DD9 16 | 17 | primary 18 | 19 | 20 | 4DB834FB1B990F1900B40DD9 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // iOS~runtime理解 4 | // 5 | // Created by 黄成都 on 15/9/4. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // iOS~runtime理解 4 | // 5 | // Created by 黄成都 on 15/9/4. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | -(void)doTest; 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // iOS~runtime理解 4 | // 5 | // Created by 黄成都 on 15/9/4. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | #warning http://www.jianshu.com/p/927c8384855a 13 | @interface ViewController () 14 | { 15 | NSString *varusString; 16 | } 17 | @property(nonatomic,strong)NSString *customproperty; 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | unsigned int count; 25 | //获取属性列表 26 | objc_property_t *propertyList = class_copyPropertyList([self class], &count); 27 | for (unsigned int i = 0; i < count; i++) { 28 | const char *propertyName = property_getName(propertyList[i]); 29 | NSLog(@"property------>%@",[NSString stringWithUTF8String:propertyName]); 30 | } 31 | //获取方法列表 32 | 33 | } 34 | 35 | - (void)didReceiveMemoryWarning { 36 | [super didReceiveMemoryWarning]; 37 | // Dispose of any resources that can be recreated. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // iOS~runtime理解 4 | // 5 | // Created by 黄成都 on 15/9/4. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | ---.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /iOS~runtime理解/iOS~runtime理解Tests/iOS_runtime__Tests.m: -------------------------------------------------------------------------------- 1 | // 2 | // iOS_runtime__Tests.m 3 | // iOS~runtime理解Tests 4 | // 5 | // Created by 黄成都 on 15/9/4. 6 | // Copyright (c) 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface iOS_runtime__Tests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation iOS_runtime__Tests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/iOSRunTimeRunLoopExplore/aba09286da575b2fdc48ad4584df830398092c29/自己动手实现 KVO/自己动手实现 KVO.xcodeproj/project.xcworkspace/xcuserdata/yifan.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO.xcodeproj/xcuserdata/yifan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 自己动手实现 KVO.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD2BAD741BC64B10000EBA4F 16 | 17 | primary 18 | 19 | 20 | DD2BAD8D1BC64B11000EBA4F 21 | 22 | primary 23 | 24 | 25 | DD2BAD981BC64B11000EBA4F 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NSObject+HCDKVO.h" 11 | @interface ViewController () 12 | @property (weak, nonatomic) IBOutlet UITextField *textField; 13 | 14 | 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | 23 | 24 | __weak UITextField *weakTextField = self.textField; 25 | [self.textField HCD_addobserver:self forkey:NSStringFromSelector(@selector(text)) withBlock:^(id observerObject, NSString *observedKey, id oldValue, id newValue) { 26 | NSLog(@"%@.%@ is now: %@", observerObject, observedKey, newValue); 27 | dispatch_async(dispatch_get_main_queue(), ^{ 28 | weakTextField.text = newValue; 29 | }); 30 | 31 | }]; 32 | 33 | 34 | [self changeClick:nil]; 35 | 36 | 37 | } 38 | 39 | 40 | - (IBAction)changeClick:(id)sender { 41 | 42 | NSArray *msgs = @[@"Hello World!", @"Objective C", @"Swift", @"Peng Gu", @"peng.gu@me.com", @"www.gupeng.me", @"glowing.com"]; 43 | NSUInteger index = arc4random_uniform((u_int32_t)msgs.count); 44 | self.textField.text = msgs[index]; 45 | } 46 | 47 | 48 | 49 | 50 | - (void)didReceiveMemoryWarning { 51 | [super didReceiveMemoryWarning]; 52 | // Dispose of any resources that can be recreated. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/自定义KVO/HCDObservationInfo.h: -------------------------------------------------------------------------------- 1 | // 2 | // HCDObservationInfo.h 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/10. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HCDObservationInfo : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/自定义KVO/HCDObservationInfo.m: -------------------------------------------------------------------------------- 1 | // 2 | // HCDObservationInfo.m 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/10. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "HCDObservationInfo.h" 10 | 11 | @implementation HCDObservationInfo 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/自定义KVO/NSObject+HCDKVO.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKVO.h 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^HCDObservingBlock)(id observerObject,NSString *observedKey, id oldValue, id newValue); 12 | 13 | @interface NSObject (HCDKVO) 14 | 15 | -(void)HCD_addobserver:(NSObject *)observer forkey:(NSString *)key withBlock:(HCDObservingBlock)block; 16 | -(void)HCD_removeObserver:(NSObject *)observer forkey:(NSString *)key; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVO/自定义KVO/NSObject+HCDKVO.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+HCDKVO.m 3 | // 自己动手实现 KVO 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import "NSObject+HCDKVO.h" 10 | #import 11 | #import 12 | 13 | NSString *const kPGKVOClassPrefix = @"PGKVOClassPrefix_"; 14 | NSString *const kPGKVOAssociatedObservers = @"PGKVOAssociatedObservers"; 15 | 16 | /** 17 | * 把setter方法转换为getter方法 18 | * 19 | * @param getter getter方法 20 | * 21 | * @return 返回对应的setter方法 22 | */ 23 | static NSString * setterForGetter(NSString *getter) 24 | { 25 | if (getter.length <= 0) { 26 | return nil; 27 | } 28 | 29 | // 把getter方法的第一个字母大写 30 | NSString *firstLetter = [[getter substringToIndex:1] uppercaseString]; 31 | NSString *remainingLetters = [getter substringFromIndex:1]; 32 | 33 | // 添加‘set’和':' 34 | NSString *setter = [NSString stringWithFormat:@"set%@%@:", firstLetter, remainingLetters]; 35 | 36 | return setter; 37 | } 38 | 39 | 40 | @implementation NSObject (HCDKVO) 41 | -(void)HCD_addobserver:(NSObject *)observer forkey:(NSString *)key withBlock:(HCDObservingBlock)block{ 42 | //1如果这个类或者父类没有实现指定属性的setter方法,抛出异常 43 | SEL setterSelector = NSSelectorFromString(setterForGetter(key)); 44 | Method setterMethod = class_getInstanceMethod([self class], setterSelector); 45 | NSAssert(!setterMethod, @"没有对应的setter方法"); 46 | 47 | Class clazz = object_getClass(self); 48 | NSString *clazzName = NSStringFromClass(clazz); 49 | 50 | //2 检查对象 isa 指向的类是不是一个 KVO 类。如果不是,新建一个继承原来类的子类,并把 isa 指向这个新建的子类; 51 | // if ([clazzName hasPrefix:<#(nonnull NSString *)#>]) { 52 | // <#statements#> 53 | // } 54 | 55 | 56 | 57 | } 58 | @end 59 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVOTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVOTests/_______KVOTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // _______KVOTests.m 3 | // 自己动手实现 KVOTests 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface _______KVOTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation _______KVOTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVOUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /自己动手实现 KVO/自己动手实现 KVOUITests/_______KVOUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // _______KVOUITests.m 3 | // 自己动手实现 KVOUITests 4 | // 5 | // Created by yifan on 15/10/8. 6 | // Copyright © 2015年 黄成都. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface _______KVOUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation _______KVOUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------