├── README.md ├── WXSRuntime.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── wangxiaoshu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── wangxiaoshu.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── WXSRuntime.xcscheme │ └── xcschememanagement.plist ├── WXSRuntime ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── NSObject+AddProperty.h ├── NSObject+AddProperty.m ├── ShowExchange.h ├── ShowExchange.m ├── TestModel.h ├── TestModel.m ├── UIViewController+WXSSwizzing.h ├── UIViewController+WXSSwizzing.m ├── ViewController.h ├── ViewController.m ├── WXSHookViewController.h ├── WXSHookViewController.m ├── WXSMessage.h ├── WXSMessage.m ├── WXSMethod.h ├── WXSMethod.m ├── WXSModel.h ├── WXSModel.m └── main.m ├── WXSRuntimeTests ├── Info.plist └── WXSRuntimeTests.m └── WXSRuntimeUITests ├── Info.plist └── WXSRuntimeUITests.m /README.md: -------------------------------------------------------------------------------- 1 | # WXSRuntime 2 | 3 | 这是学习runtime 的一个总结性Demo 4 | 里面有runtime 的几种常见用法。 5 | 有Mehtod Var等的操作 6 | 也有Message Forwarding 7 | -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 928AEE981CC4731C009DBC1B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEE971CC4731C009DBC1B /* main.m */; }; 11 | 928AEE9B1CC4731C009DBC1B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEE9A1CC4731C009DBC1B /* AppDelegate.m */; }; 12 | 928AEE9E1CC4731C009DBC1B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEE9D1CC4731C009DBC1B /* ViewController.m */; }; 13 | 928AEEA11CC4731C009DBC1B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 928AEE9F1CC4731C009DBC1B /* Main.storyboard */; }; 14 | 928AEEA31CC4731C009DBC1B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 928AEEA21CC4731C009DBC1B /* Assets.xcassets */; }; 15 | 928AEEA61CC4731C009DBC1B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 928AEEA41CC4731C009DBC1B /* LaunchScreen.storyboard */; }; 16 | 928AEEB11CC4731C009DBC1B /* WXSRuntimeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEEB01CC4731C009DBC1B /* WXSRuntimeTests.m */; }; 17 | 928AEEBC1CC4731C009DBC1B /* WXSRuntimeUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEEBB1CC4731C009DBC1B /* WXSRuntimeUITests.m */; }; 18 | 928AEECB1CC483BE009DBC1B /* WXSModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 928AEECA1CC483BE009DBC1B /* WXSModel.m */; }; 19 | 92A0081C1CCF45F400852890 /* ShowExchange.m in Sources */ = {isa = PBXBuildFile; fileRef = 92A0081B1CCF45F400852890 /* ShowExchange.m */; }; 20 | 92E5E8021CC8690600135710 /* NSObject+AddProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 92E5E8011CC8690600135710 /* NSObject+AddProperty.m */; }; 21 | 92E5E80B1CC896E300135710 /* WXSMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 92E5E80A1CC896E300135710 /* WXSMessage.m */; }; 22 | 92E5E80E1CCA150E00135710 /* WXSMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 92E5E80D1CCA150E00135710 /* WXSMethod.m */; }; 23 | 92FA4E461CC5DA770034A0AB /* TestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FA4E451CC5DA770034A0AB /* TestModel.m */; }; 24 | 92FA4E491CC740EA0034A0AB /* UIViewController+WXSSwizzing.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FA4E481CC740EA0034A0AB /* UIViewController+WXSSwizzing.m */; }; 25 | 92FA4E521CC783080034A0AB /* WXSHookViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FA4E511CC783080034A0AB /* WXSHookViewController.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 928AEEAD1CC4731C009DBC1B /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 928AEE8B1CC4731C009DBC1B /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 928AEE921CC4731C009DBC1B; 34 | remoteInfo = WXSRuntime; 35 | }; 36 | 928AEEB81CC4731C009DBC1B /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = 928AEE8B1CC4731C009DBC1B /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = 928AEE921CC4731C009DBC1B; 41 | remoteInfo = WXSRuntime; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | 928AEE931CC4731C009DBC1B /* WXSRuntime.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WXSRuntime.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | 928AEE971CC4731C009DBC1B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 48 | 928AEE991CC4731C009DBC1B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | 928AEE9A1CC4731C009DBC1B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | 928AEE9C1CC4731C009DBC1B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 51 | 928AEE9D1CC4731C009DBC1B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 52 | 928AEEA01CC4731C009DBC1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | 928AEEA21CC4731C009DBC1B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | 928AEEA51CC4731C009DBC1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | 928AEEA71CC4731C009DBC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 928AEEAC1CC4731C009DBC1B /* WXSRuntimeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WXSRuntimeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 928AEEB01CC4731C009DBC1B /* WXSRuntimeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXSRuntimeTests.m; sourceTree = ""; }; 58 | 928AEEB21CC4731C009DBC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 928AEEB71CC4731C009DBC1B /* WXSRuntimeUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = WXSRuntimeUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | 928AEEBB1CC4731C009DBC1B /* WXSRuntimeUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXSRuntimeUITests.m; sourceTree = ""; }; 61 | 928AEEBD1CC4731C009DBC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | 928AEEC91CC483BE009DBC1B /* WXSModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSModel.h; sourceTree = ""; }; 63 | 928AEECA1CC483BE009DBC1B /* WXSModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSModel.m; sourceTree = ""; }; 64 | 92A0081A1CCF45F400852890 /* ShowExchange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShowExchange.h; sourceTree = ""; }; 65 | 92A0081B1CCF45F400852890 /* ShowExchange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShowExchange.m; sourceTree = ""; }; 66 | 92E5E8001CC8690600135710 /* NSObject+AddProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+AddProperty.h"; sourceTree = ""; }; 67 | 92E5E8011CC8690600135710 /* NSObject+AddProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+AddProperty.m"; sourceTree = ""; }; 68 | 92E5E8091CC896E300135710 /* WXSMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSMessage.h; sourceTree = ""; }; 69 | 92E5E80A1CC896E300135710 /* WXSMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSMessage.m; sourceTree = ""; }; 70 | 92E5E80C1CCA150D00135710 /* WXSMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSMethod.h; sourceTree = ""; }; 71 | 92E5E80D1CCA150E00135710 /* WXSMethod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSMethod.m; sourceTree = ""; }; 72 | 92FA4E441CC5DA770034A0AB /* TestModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestModel.h; sourceTree = ""; }; 73 | 92FA4E451CC5DA770034A0AB /* TestModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestModel.m; sourceTree = ""; }; 74 | 92FA4E471CC740EA0034A0AB /* UIViewController+WXSSwizzing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+WXSSwizzing.h"; sourceTree = ""; }; 75 | 92FA4E481CC740EA0034A0AB /* UIViewController+WXSSwizzing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+WXSSwizzing.m"; sourceTree = ""; }; 76 | 92FA4E501CC783080034A0AB /* WXSHookViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXSHookViewController.h; sourceTree = ""; }; 77 | 92FA4E511CC783080034A0AB /* WXSHookViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXSHookViewController.m; sourceTree = ""; }; 78 | /* End PBXFileReference section */ 79 | 80 | /* Begin PBXFrameworksBuildPhase section */ 81 | 928AEE901CC4731C009DBC1B /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | 928AEEA91CC4731C009DBC1B /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | ); 93 | runOnlyForDeploymentPostprocessing = 0; 94 | }; 95 | 928AEEB41CC4731C009DBC1B /* Frameworks */ = { 96 | isa = PBXFrameworksBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | /* End PBXFrameworksBuildPhase section */ 103 | 104 | /* Begin PBXGroup section */ 105 | 928AEE8A1CC4731C009DBC1B = { 106 | isa = PBXGroup; 107 | children = ( 108 | 928AEE951CC4731C009DBC1B /* WXSRuntime */, 109 | 928AEEAF1CC4731C009DBC1B /* WXSRuntimeTests */, 110 | 928AEEBA1CC4731C009DBC1B /* WXSRuntimeUITests */, 111 | 928AEE941CC4731C009DBC1B /* Products */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | 928AEE941CC4731C009DBC1B /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 928AEE931CC4731C009DBC1B /* WXSRuntime.app */, 119 | 928AEEAC1CC4731C009DBC1B /* WXSRuntimeTests.xctest */, 120 | 928AEEB71CC4731C009DBC1B /* WXSRuntimeUITests.xctest */, 121 | ); 122 | name = Products; 123 | sourceTree = ""; 124 | }; 125 | 928AEE951CC4731C009DBC1B /* WXSRuntime */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 928AEE9A1CC4731C009DBC1B /* AppDelegate.m */, 129 | 928AEE991CC4731C009DBC1B /* AppDelegate.h */, 130 | 928AEE9C1CC4731C009DBC1B /* ViewController.h */, 131 | 928AEE9D1CC4731C009DBC1B /* ViewController.m */, 132 | 92FA4E441CC5DA770034A0AB /* TestModel.h */, 133 | 92FA4E451CC5DA770034A0AB /* TestModel.m */, 134 | 928AEEC91CC483BE009DBC1B /* WXSModel.h */, 135 | 928AEECA1CC483BE009DBC1B /* WXSModel.m */, 136 | 92FA4E471CC740EA0034A0AB /* UIViewController+WXSSwizzing.h */, 137 | 92FA4E481CC740EA0034A0AB /* UIViewController+WXSSwizzing.m */, 138 | 92A0081A1CCF45F400852890 /* ShowExchange.h */, 139 | 92A0081B1CCF45F400852890 /* ShowExchange.m */, 140 | 92FA4E501CC783080034A0AB /* WXSHookViewController.h */, 141 | 92FA4E511CC783080034A0AB /* WXSHookViewController.m */, 142 | 92E5E8001CC8690600135710 /* NSObject+AddProperty.h */, 143 | 92E5E8011CC8690600135710 /* NSObject+AddProperty.m */, 144 | 92E5E8091CC896E300135710 /* WXSMessage.h */, 145 | 92E5E80A1CC896E300135710 /* WXSMessage.m */, 146 | 92E5E80C1CCA150D00135710 /* WXSMethod.h */, 147 | 92E5E80D1CCA150E00135710 /* WXSMethod.m */, 148 | 928AEE9F1CC4731C009DBC1B /* Main.storyboard */, 149 | 928AEEA21CC4731C009DBC1B /* Assets.xcassets */, 150 | 928AEEA41CC4731C009DBC1B /* LaunchScreen.storyboard */, 151 | 928AEEA71CC4731C009DBC1B /* Info.plist */, 152 | 928AEE961CC4731C009DBC1B /* Supporting Files */, 153 | ); 154 | path = WXSRuntime; 155 | sourceTree = ""; 156 | }; 157 | 928AEE961CC4731C009DBC1B /* Supporting Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 928AEE971CC4731C009DBC1B /* main.m */, 161 | ); 162 | name = "Supporting Files"; 163 | sourceTree = ""; 164 | }; 165 | 928AEEAF1CC4731C009DBC1B /* WXSRuntimeTests */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 928AEEB01CC4731C009DBC1B /* WXSRuntimeTests.m */, 169 | 928AEEB21CC4731C009DBC1B /* Info.plist */, 170 | ); 171 | path = WXSRuntimeTests; 172 | sourceTree = ""; 173 | }; 174 | 928AEEBA1CC4731C009DBC1B /* WXSRuntimeUITests */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | 928AEEBB1CC4731C009DBC1B /* WXSRuntimeUITests.m */, 178 | 928AEEBD1CC4731C009DBC1B /* Info.plist */, 179 | ); 180 | path = WXSRuntimeUITests; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXGroup section */ 184 | 185 | /* Begin PBXNativeTarget section */ 186 | 928AEE921CC4731C009DBC1B /* WXSRuntime */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 928AEEC01CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntime" */; 189 | buildPhases = ( 190 | 928AEE8F1CC4731C009DBC1B /* Sources */, 191 | 928AEE901CC4731C009DBC1B /* Frameworks */, 192 | 928AEE911CC4731C009DBC1B /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = WXSRuntime; 199 | productName = WXSRuntime; 200 | productReference = 928AEE931CC4731C009DBC1B /* WXSRuntime.app */; 201 | productType = "com.apple.product-type.application"; 202 | }; 203 | 928AEEAB1CC4731C009DBC1B /* WXSRuntimeTests */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 928AEEC31CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntimeTests" */; 206 | buildPhases = ( 207 | 928AEEA81CC4731C009DBC1B /* Sources */, 208 | 928AEEA91CC4731C009DBC1B /* Frameworks */, 209 | 928AEEAA1CC4731C009DBC1B /* Resources */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | 928AEEAE1CC4731C009DBC1B /* PBXTargetDependency */, 215 | ); 216 | name = WXSRuntimeTests; 217 | productName = WXSRuntimeTests; 218 | productReference = 928AEEAC1CC4731C009DBC1B /* WXSRuntimeTests.xctest */; 219 | productType = "com.apple.product-type.bundle.unit-test"; 220 | }; 221 | 928AEEB61CC4731C009DBC1B /* WXSRuntimeUITests */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 928AEEC61CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntimeUITests" */; 224 | buildPhases = ( 225 | 928AEEB31CC4731C009DBC1B /* Sources */, 226 | 928AEEB41CC4731C009DBC1B /* Frameworks */, 227 | 928AEEB51CC4731C009DBC1B /* Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | 928AEEB91CC4731C009DBC1B /* PBXTargetDependency */, 233 | ); 234 | name = WXSRuntimeUITests; 235 | productName = WXSRuntimeUITests; 236 | productReference = 928AEEB71CC4731C009DBC1B /* WXSRuntimeUITests.xctest */; 237 | productType = "com.apple.product-type.bundle.ui-testing"; 238 | }; 239 | /* End PBXNativeTarget section */ 240 | 241 | /* Begin PBXProject section */ 242 | 928AEE8B1CC4731C009DBC1B /* Project object */ = { 243 | isa = PBXProject; 244 | attributes = { 245 | LastUpgradeCheck = 0720; 246 | ORGANIZATIONNAME = "王小树"; 247 | TargetAttributes = { 248 | 928AEE921CC4731C009DBC1B = { 249 | CreatedOnToolsVersion = 7.2.1; 250 | }; 251 | 928AEEAB1CC4731C009DBC1B = { 252 | CreatedOnToolsVersion = 7.2.1; 253 | TestTargetID = 928AEE921CC4731C009DBC1B; 254 | }; 255 | 928AEEB61CC4731C009DBC1B = { 256 | CreatedOnToolsVersion = 7.2.1; 257 | TestTargetID = 928AEE921CC4731C009DBC1B; 258 | }; 259 | }; 260 | }; 261 | buildConfigurationList = 928AEE8E1CC4731C009DBC1B /* Build configuration list for PBXProject "WXSRuntime" */; 262 | compatibilityVersion = "Xcode 3.2"; 263 | developmentRegion = English; 264 | hasScannedForEncodings = 0; 265 | knownRegions = ( 266 | en, 267 | Base, 268 | ); 269 | mainGroup = 928AEE8A1CC4731C009DBC1B; 270 | productRefGroup = 928AEE941CC4731C009DBC1B /* Products */; 271 | projectDirPath = ""; 272 | projectRoot = ""; 273 | targets = ( 274 | 928AEE921CC4731C009DBC1B /* WXSRuntime */, 275 | 928AEEAB1CC4731C009DBC1B /* WXSRuntimeTests */, 276 | 928AEEB61CC4731C009DBC1B /* WXSRuntimeUITests */, 277 | ); 278 | }; 279 | /* End PBXProject section */ 280 | 281 | /* Begin PBXResourcesBuildPhase section */ 282 | 928AEE911CC4731C009DBC1B /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 928AEEA61CC4731C009DBC1B /* LaunchScreen.storyboard in Resources */, 287 | 928AEEA31CC4731C009DBC1B /* Assets.xcassets in Resources */, 288 | 928AEEA11CC4731C009DBC1B /* Main.storyboard in Resources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 928AEEAA1CC4731C009DBC1B /* Resources */ = { 293 | isa = PBXResourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | 928AEEB51CC4731C009DBC1B /* Resources */ = { 300 | isa = PBXResourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXResourcesBuildPhase section */ 307 | 308 | /* Begin PBXSourcesBuildPhase section */ 309 | 928AEE8F1CC4731C009DBC1B /* Sources */ = { 310 | isa = PBXSourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 928AEECB1CC483BE009DBC1B /* WXSModel.m in Sources */, 314 | 92A0081C1CCF45F400852890 /* ShowExchange.m in Sources */, 315 | 92E5E80B1CC896E300135710 /* WXSMessage.m in Sources */, 316 | 92FA4E461CC5DA770034A0AB /* TestModel.m in Sources */, 317 | 92E5E8021CC8690600135710 /* NSObject+AddProperty.m in Sources */, 318 | 92FA4E521CC783080034A0AB /* WXSHookViewController.m in Sources */, 319 | 928AEE9E1CC4731C009DBC1B /* ViewController.m in Sources */, 320 | 928AEE9B1CC4731C009DBC1B /* AppDelegate.m in Sources */, 321 | 92FA4E491CC740EA0034A0AB /* UIViewController+WXSSwizzing.m in Sources */, 322 | 928AEE981CC4731C009DBC1B /* main.m in Sources */, 323 | 92E5E80E1CCA150E00135710 /* WXSMethod.m in Sources */, 324 | ); 325 | runOnlyForDeploymentPostprocessing = 0; 326 | }; 327 | 928AEEA81CC4731C009DBC1B /* Sources */ = { 328 | isa = PBXSourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | 928AEEB11CC4731C009DBC1B /* WXSRuntimeTests.m in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | 928AEEB31CC4731C009DBC1B /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | 928AEEBC1CC4731C009DBC1B /* WXSRuntimeUITests.m in Sources */, 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | /* End PBXSourcesBuildPhase section */ 344 | 345 | /* Begin PBXTargetDependency section */ 346 | 928AEEAE1CC4731C009DBC1B /* PBXTargetDependency */ = { 347 | isa = PBXTargetDependency; 348 | target = 928AEE921CC4731C009DBC1B /* WXSRuntime */; 349 | targetProxy = 928AEEAD1CC4731C009DBC1B /* PBXContainerItemProxy */; 350 | }; 351 | 928AEEB91CC4731C009DBC1B /* PBXTargetDependency */ = { 352 | isa = PBXTargetDependency; 353 | target = 928AEE921CC4731C009DBC1B /* WXSRuntime */; 354 | targetProxy = 928AEEB81CC4731C009DBC1B /* PBXContainerItemProxy */; 355 | }; 356 | /* End PBXTargetDependency section */ 357 | 358 | /* Begin PBXVariantGroup section */ 359 | 928AEE9F1CC4731C009DBC1B /* Main.storyboard */ = { 360 | isa = PBXVariantGroup; 361 | children = ( 362 | 928AEEA01CC4731C009DBC1B /* Base */, 363 | ); 364 | name = Main.storyboard; 365 | sourceTree = ""; 366 | }; 367 | 928AEEA41CC4731C009DBC1B /* LaunchScreen.storyboard */ = { 368 | isa = PBXVariantGroup; 369 | children = ( 370 | 928AEEA51CC4731C009DBC1B /* Base */, 371 | ); 372 | name = LaunchScreen.storyboard; 373 | sourceTree = ""; 374 | }; 375 | /* End PBXVariantGroup section */ 376 | 377 | /* Begin XCBuildConfiguration section */ 378 | 928AEEBE1CC4731C009DBC1B /* Debug */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ALWAYS_SEARCH_USER_PATHS = NO; 382 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 383 | CLANG_CXX_LIBRARY = "libc++"; 384 | CLANG_ENABLE_MODULES = YES; 385 | CLANG_ENABLE_OBJC_ARC = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_CONSTANT_CONVERSION = YES; 388 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 389 | CLANG_WARN_EMPTY_BODY = YES; 390 | CLANG_WARN_ENUM_CONVERSION = YES; 391 | CLANG_WARN_INT_CONVERSION = YES; 392 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 393 | CLANG_WARN_UNREACHABLE_CODE = YES; 394 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 395 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 396 | COPY_PHASE_STRIP = NO; 397 | DEBUG_INFORMATION_FORMAT = dwarf; 398 | ENABLE_STRICT_OBJC_MSGSEND = YES; 399 | ENABLE_TESTABILITY = YES; 400 | GCC_C_LANGUAGE_STANDARD = gnu99; 401 | GCC_DYNAMIC_NO_PIC = NO; 402 | GCC_NO_COMMON_BLOCKS = YES; 403 | GCC_OPTIMIZATION_LEVEL = 0; 404 | GCC_PREPROCESSOR_DEFINITIONS = ( 405 | "DEBUG=1", 406 | "$(inherited)", 407 | ); 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 415 | MTL_ENABLE_DEBUG_INFO = YES; 416 | ONLY_ACTIVE_ARCH = YES; 417 | SDKROOT = iphoneos; 418 | TARGETED_DEVICE_FAMILY = "1,2"; 419 | }; 420 | name = Debug; 421 | }; 422 | 928AEEBF1CC4731C009DBC1B /* Release */ = { 423 | isa = XCBuildConfiguration; 424 | buildSettings = { 425 | ALWAYS_SEARCH_USER_PATHS = NO; 426 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 427 | CLANG_CXX_LIBRARY = "libc++"; 428 | CLANG_ENABLE_MODULES = YES; 429 | CLANG_ENABLE_OBJC_ARC = YES; 430 | CLANG_WARN_BOOL_CONVERSION = YES; 431 | CLANG_WARN_CONSTANT_CONVERSION = YES; 432 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 433 | CLANG_WARN_EMPTY_BODY = YES; 434 | CLANG_WARN_ENUM_CONVERSION = YES; 435 | CLANG_WARN_INT_CONVERSION = YES; 436 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 437 | CLANG_WARN_UNREACHABLE_CODE = YES; 438 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 439 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 440 | COPY_PHASE_STRIP = NO; 441 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 442 | ENABLE_NS_ASSERTIONS = NO; 443 | ENABLE_STRICT_OBJC_MSGSEND = YES; 444 | GCC_C_LANGUAGE_STANDARD = gnu99; 445 | GCC_NO_COMMON_BLOCKS = YES; 446 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 447 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 448 | GCC_WARN_UNDECLARED_SELECTOR = YES; 449 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 450 | GCC_WARN_UNUSED_FUNCTION = YES; 451 | GCC_WARN_UNUSED_VARIABLE = YES; 452 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 453 | MTL_ENABLE_DEBUG_INFO = NO; 454 | SDKROOT = iphoneos; 455 | TARGETED_DEVICE_FAMILY = "1,2"; 456 | VALIDATE_PRODUCT = YES; 457 | }; 458 | name = Release; 459 | }; 460 | 928AEEC11CC4731C009DBC1B /* Debug */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 464 | INFOPLIST_FILE = WXSRuntime/Info.plist; 465 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 466 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntime; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | }; 469 | name = Debug; 470 | }; 471 | 928AEEC21CC4731C009DBC1B /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 475 | INFOPLIST_FILE = WXSRuntime/Info.plist; 476 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 477 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntime; 478 | PRODUCT_NAME = "$(TARGET_NAME)"; 479 | }; 480 | name = Release; 481 | }; 482 | 928AEEC41CC4731C009DBC1B /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | BUNDLE_LOADER = "$(TEST_HOST)"; 486 | INFOPLIST_FILE = WXSRuntimeTests/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 488 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntimeTests; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WXSRuntime.app/WXSRuntime"; 491 | }; 492 | name = Debug; 493 | }; 494 | 928AEEC51CC4731C009DBC1B /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | BUNDLE_LOADER = "$(TEST_HOST)"; 498 | INFOPLIST_FILE = WXSRuntimeTests/Info.plist; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 500 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntimeTests; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WXSRuntime.app/WXSRuntime"; 503 | }; 504 | name = Release; 505 | }; 506 | 928AEEC71CC4731C009DBC1B /* Debug */ = { 507 | isa = XCBuildConfiguration; 508 | buildSettings = { 509 | INFOPLIST_FILE = WXSRuntimeUITests/Info.plist; 510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 511 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntimeUITests; 512 | PRODUCT_NAME = "$(TARGET_NAME)"; 513 | TEST_TARGET_NAME = WXSRuntime; 514 | USES_XCTRUNNER = YES; 515 | }; 516 | name = Debug; 517 | }; 518 | 928AEEC81CC4731C009DBC1B /* Release */ = { 519 | isa = XCBuildConfiguration; 520 | buildSettings = { 521 | INFOPLIST_FILE = WXSRuntimeUITests/Info.plist; 522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 523 | PRODUCT_BUNDLE_IDENTIFIER = WSX.WXSRuntimeUITests; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | TEST_TARGET_NAME = WXSRuntime; 526 | USES_XCTRUNNER = YES; 527 | }; 528 | name = Release; 529 | }; 530 | /* End XCBuildConfiguration section */ 531 | 532 | /* Begin XCConfigurationList section */ 533 | 928AEE8E1CC4731C009DBC1B /* Build configuration list for PBXProject "WXSRuntime" */ = { 534 | isa = XCConfigurationList; 535 | buildConfigurations = ( 536 | 928AEEBE1CC4731C009DBC1B /* Debug */, 537 | 928AEEBF1CC4731C009DBC1B /* Release */, 538 | ); 539 | defaultConfigurationIsVisible = 0; 540 | defaultConfigurationName = Release; 541 | }; 542 | 928AEEC01CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntime" */ = { 543 | isa = XCConfigurationList; 544 | buildConfigurations = ( 545 | 928AEEC11CC4731C009DBC1B /* Debug */, 546 | 928AEEC21CC4731C009DBC1B /* Release */, 547 | ); 548 | defaultConfigurationIsVisible = 0; 549 | defaultConfigurationName = Release; 550 | }; 551 | 928AEEC31CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntimeTests" */ = { 552 | isa = XCConfigurationList; 553 | buildConfigurations = ( 554 | 928AEEC41CC4731C009DBC1B /* Debug */, 555 | 928AEEC51CC4731C009DBC1B /* Release */, 556 | ); 557 | defaultConfigurationIsVisible = 0; 558 | defaultConfigurationName = Release; 559 | }; 560 | 928AEEC61CC4731C009DBC1B /* Build configuration list for PBXNativeTarget "WXSRuntimeUITests" */ = { 561 | isa = XCConfigurationList; 562 | buildConfigurations = ( 563 | 928AEEC71CC4731C009DBC1B /* Debug */, 564 | 928AEEC81CC4731C009DBC1B /* Release */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | /* End XCConfigurationList section */ 570 | }; 571 | rootObject = 928AEE8B1CC4731C009DBC1B /* Project object */; 572 | } 573 | -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/project.xcworkspace/xcuserdata/wangxiaoshu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alanwangmodify/WXSRuntime/c1b6d1abd73ec3740a786b947db0b3e96ea3a0f4/WXSRuntime.xcodeproj/project.xcworkspace/xcuserdata/wangxiaoshu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcschemes/WXSRuntime.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /WXSRuntime.xcodeproj/xcuserdata/wangxiaoshu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | WXSRuntime.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 928AEE921CC4731C009DBC1B 16 | 17 | primary 18 | 19 | 20 | 928AEEAB1CC4731C009DBC1B 21 | 22 | primary 23 | 24 | 25 | 928AEEB61CC4731C009DBC1B 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /WXSRuntime/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. 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 | -------------------------------------------------------------------------------- /WXSRuntime/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /WXSRuntime/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /WXSRuntime/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 | -------------------------------------------------------------------------------- /WXSRuntime/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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /WXSRuntime/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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /WXSRuntime/NSObject+AddProperty.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+AddProperty.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/21. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | typedef void(^TestBlock)(); 13 | @interface NSObject (AddProperty) 14 | 15 | @property (nonatomic,strong) NSString *wxsTitle; 16 | @property (nonatomic,copy) TestBlock testBlock; 17 | 18 | +(void)logforTest; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /WXSRuntime/NSObject+AddProperty.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+AddProperty.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/21. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "NSObject+AddProperty.h" 10 | 11 | static const void *WXSAddPropertyKeyTitle = @"WXSAddPropertyKeyTitle"; 12 | static const void *WXSAddPropertyKeyTestBlock = @"WXSAddPropertyKeyTestBlock"; 13 | @implementation NSObject (AddProperty) 14 | 15 | -(void)setWxsTitle:(NSString *)wxsTitle { 16 | objc_setAssociatedObject(self, WXSAddPropertyKeyTitle, wxsTitle, OBJC_ASSOCIATION_RETAIN); 17 | } 18 | -(NSString *)wxsTitle { 19 | return objc_getAssociatedObject(self, WXSAddPropertyKeyTitle); 20 | } 21 | 22 | 23 | -(void)setTestBlock:(TestBlock)testBlock { 24 | objc_setAssociatedObject(self, WXSAddPropertyKeyTestBlock, testBlock, OBJC_ASSOCIATION_COPY); 25 | } 26 | -(TestBlock)testBlock { 27 | return objc_getAssociatedObject(self, WXSAddPropertyKeyTestBlock); 28 | } 29 | 30 | +(void)logforTest { 31 | NSString *str = @"s"; 32 | str.testBlock = ^() { 33 | NSLog(@"这是block"); 34 | }; 35 | str.testBlock(); 36 | 37 | [str setWxsTitle:@"类别title"]; 38 | NSLog(@"-----%@",str.wxsTitle); 39 | 40 | } 41 | @end 42 | -------------------------------------------------------------------------------- /WXSRuntime/ShowExchange.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShowExchange.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/26. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface ShowExchange : NSObject 13 | 14 | -(void)firstMethod; 15 | -(void)secondMethod; 16 | +(void)forTest; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /WXSRuntime/ShowExchange.m: -------------------------------------------------------------------------------- 1 | // 2 | // ShowExchange.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/26. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "ShowExchange.h" 10 | 11 | @implementation ShowExchange 12 | -(void)firstMethod { 13 | NSLog(@"firstMethod"); 14 | } 15 | -(void)secondMethod{ 16 | NSLog(@"secondMethod"); 17 | } 18 | +(void)forTest { 19 | 20 | NSLog(@"------Normal-----\n"); 21 | ShowExchange *normarlTest = [ShowExchange new]; 22 | [normarlTest firstMethod]; 23 | NSLog(@"------Normal-----\n"); 24 | 25 | //交换实例方法 26 | NSLog(@"------exchange-----\n"); 27 | 28 | Method m1 = class_getInstanceMethod([ShowExchange class], @selector(firstMethod)); 29 | Method m2 = class_getInstanceMethod([ShowExchange class], @selector(secondMethod)); 30 | method_exchangeImplementations(m1, m2); 31 | 32 | ShowExchange *test = [ShowExchange new]; 33 | [test firstMethod]; 34 | NSLog(@"------exchange InstanceMethod-----\n"); 35 | 36 | } 37 | @end 38 | -------------------------------------------------------------------------------- /WXSRuntime/TestModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // TestModel.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/19. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "WXSModel.h" 10 | 11 | @interface TestModel : WXSModel 12 | 13 | @property (nonatomic,strong) NSString *myUrl; 14 | @property (nonatomic,strong) NSString *name; 15 | @property (nonatomic,strong) NSDictionary *dict; 16 | @property (nonatomic,strong) NSString *title; 17 | @property (nonatomic,strong) NSDictionary *testNil; 18 | @property (nonatomic,assign) NSInteger num; 19 | @property (nonatomic,strong) NSArray *array; 20 | @property (nonatomic,strong) NSNumber *number; 21 | 22 | 23 | 24 | 25 | 26 | +(void)forTest; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /WXSRuntime/TestModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // TestModel.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/19. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "TestModel.h" 10 | 11 | @implementation TestModel 12 | 13 | 14 | +(void)forTest { 15 | 16 | 17 | NSDictionary *dict = @{ 18 | @"name" : @"王小树 Alan_iOS", 19 | @"title" : @"Model", 20 | @"num" : @(20), 21 | @"array" : @[@"1", @"2", @"3"], 22 | @"dict" : @{@"key1" : @"value1", @"key2":@"value2"}, 23 | @"myUrl" :@"http://www.jianshu.com/p/f73ea068efd2" 24 | }; 25 | 26 | 27 | TestModel *model = [[TestModel alloc]initWithDic:dict]; 28 | 29 | 30 | NSDictionary *tem = [model modelToDic]; 31 | NSLog(@"%@",tem); 32 | 33 | 34 | NSString *path = [NSString stringWithFormat:@"%@/archive",NSHomeDirectory()]; 35 | [NSKeyedArchiver archiveRootObject:model toFile:path]; 36 | 37 | TestModel *otherModel = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; 38 | 39 | NSLog(@"otherMoel:%@",otherModel.name); 40 | 41 | } 42 | @end 43 | -------------------------------------------------------------------------------- /WXSRuntime/UIViewController+WXSSwizzing.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+WXSSwizzing.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/20. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface UIViewController (WXSSwizzing) 13 | 14 | 15 | -(void)wxscount; 16 | -(void)count; 17 | +(void)forTest; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /WXSRuntime/UIViewController+WXSSwizzing.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+WXSSwizzing.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/20. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+WXSSwizzing.h" 10 | 11 | 12 | @implementation UIViewController (WXSSwizzing) 13 | 14 | -(void)wxscount { 15 | NSLog(@"变成了wxsCount"); 16 | } 17 | -(void)count { 18 | NSLog(@"count"); 19 | } 20 | 21 | +(void)forTest{ 22 | UIViewController *vc = [[UIViewController alloc] init]; 23 | Method m1 = class_getClassMethod([vc class], @selector(count)); 24 | Method m2 = class_getClassMethod([vc class], @selector(wxscount)); 25 | method_exchangeImplementations(m1, m2); 26 | BOOL isSuccess = class_addMethod([vc class], @selector(count), method_getImplementation(m2), method_getTypeEncoding(m2)); 27 | if (isSuccess) { 28 | // 添加成功:将源方法的实现替换到交换方法的实现 29 | // count方法实现被m2实现替换 30 | class_replaceMethod([vc class], @selector(wxscount), method_getImplementation(m2), method_getTypeEncoding(m2)); 31 | }else { 32 | //添加失败:说明源方法已经有实现,直接将两个方法的实现交换即 33 | 34 | } 35 | 36 | [vc count]; 37 | } 38 | @end 39 | -------------------------------------------------------------------------------- /WXSRuntime/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WXSHookViewController.h" 11 | #import "NSObject+AddProperty.h" 12 | #import "UIViewController+WXSSwizzing.h" 13 | #import "WXSMessage.h" 14 | #import "WXSMethod.h" 15 | #import "ShowExchange.h" 16 | @interface ViewController : UIViewController 17 | 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /WXSRuntime/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "TestModel.h" 11 | @interface ViewController () 12 | { 13 | NSArray *_nameArr; 14 | 15 | } 16 | @property (nonatomic,strong) UITableView *tableView; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | [self.view addSubview:self.tableView]; 26 | _nameArr = @[@"字典转模型的自动转换 和 自动归档解档",@"方法交换",@"类别添加属性",@"消息转发",@"Mehtod操作",@"Hook"]; 27 | 28 | } 29 | -(UITableView *)tableView { 30 | if (!_tableView) { 31 | _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; 32 | _tableView.delegate = self; 33 | _tableView.dataSource = self; 34 | _tableView.tableFooterView = [UIView new]; 35 | } 36 | return _tableView; 37 | } 38 | #pragma mark Delegate and Datasource 39 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 40 | return _nameArr.count; 41 | } 42 | 43 | 44 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 45 | static NSString *identifier = @"cell"; 46 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 47 | if (cell == nil) { 48 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; 49 | } 50 | cell.textLabel.text = _nameArr[indexPath.row]; 51 | return cell; 52 | 53 | } 54 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 55 | switch (indexPath.row) { 56 | case 0:{ 57 | [TestModel forTest]; 58 | } 59 | break; 60 | case 1: { 61 | [ShowExchange forTest]; 62 | } 63 | break; 64 | case 2:{ 65 | [NSObject logforTest]; 66 | } 67 | case 3:{ 68 | [WXSMessage test]; 69 | } 70 | break; 71 | case 4:{ 72 | [WXSMethod forTest]; 73 | } 74 | break; 75 | case 5:{ 76 | WXSHookViewController *vc = [[WXSHookViewController alloc] init]; 77 | [self.navigationController pushViewController:vc animated:YES]; 78 | } 79 | break; 80 | 81 | default: 82 | break; 83 | } 84 | } 85 | 86 | 87 | - (void)didReceiveMemoryWarning { 88 | [super didReceiveMemoryWarning]; 89 | } 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /WXSRuntime/WXSHookViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXSHookViewController.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/20. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface WXSHookViewController : UIViewController 14 | - (void)wxs_viewWillAppear:(BOOL)animated; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /WXSRuntime/WXSHookViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSHookViewController.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/20. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "WXSHookViewController.h" 10 | 11 | @interface WXSHookViewController () 12 | 13 | @end 14 | 15 | @implementation WXSHookViewController 16 | 17 | 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | Method m1 = class_getInstanceMethod([self class], @selector(viewWillAppear:)); 22 | Method m2 = class_getInstanceMethod([self class], @selector(wxs_viewWillAppear:)); 23 | 24 | BOOL isSuccess = class_addMethod([self class], @selector(viewWillAppear:), method_getImplementation(m2), method_getTypeEncoding(m2)); 25 | if (isSuccess) { 26 | // 添加成功:说明源方法m1现在的实现为交换方法m2的实现,现在将源方法m1的实现替换到交换方法m2中 27 | 28 | class_replaceMethod([self class], @selector(wxs_viewWillAppear:), method_getImplementation(m1), method_getTypeEncoding(m1)); 29 | }else { 30 | //添加失败:说明源方法已经有实现,直接将两个方法的实现交换即 31 | method_exchangeImplementations(m1, m2); 32 | } 33 | } 34 | -(void)viewWillAppear:(BOOL)animated { 35 | NSLog(@"viewWillAppear"); 36 | } 37 | - (void)wxs_viewWillAppear:(BOOL)animated { 38 | NSLog(@"Hook : 拦截到viewwillApear的实现,在其基础上添加了这行代码"); 39 | [self wxs_viewWillAppear:YES]; 40 | } 41 | 42 | 43 | - (void)didReceiveMemoryWarning { 44 | [super didReceiveMemoryWarning]; 45 | } 46 | 47 | 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /WXSRuntime/WXSMessage.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXSMessage.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/21. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface WXSMessage : NSObject 13 | 14 | 15 | -(void)dynamicMehod; 16 | + (void)test; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /WXSRuntime/WXSMessage.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSMessage.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/21. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "WXSMessage.h" 10 | 11 | @implementation WXSMessage 12 | 13 | 14 | // 第一步:实现此方法,在调用对象的某方法找不到时,会先调用此方法,允许 15 | // 我们动态添加方法实现 16 | + (BOOL)resolveInstanceMethod:(SEL)sel { 17 | // 我们这里没有声明有eat方法,因此,我们可以动态添加eat方法 18 | if ([NSStringFromSelector(sel) isEqualToString:@"dynamicMehod"]) { 19 | class_addMethod(self, sel, (IMP)dynamicMehod, "v@:"); 20 | return YES; 21 | } 22 | return [super resolveInstanceMethod:sel]; 23 | } 24 | 25 | // 动态添加方法 26 | void dynamicMehod(id self, SEL cmd) { 27 | NSLog(@"%@ dynamicMehod", self); 28 | } 29 | 30 | 31 | // 第二步,备选提供响应aSelector的对象,我们不备选,因此设置为nil,就会进入第三步 32 | // 上一步返回NO,就会进入这一步,用于指定备选响应此SEL的对象 33 | // 千万不能返回self,否则就会死循环 34 | // 自己没有实现这个方法才会进入这一流程,因此成为死循环 35 | - (id)forwardingTargetForSelector:(SEL)aSelector { 36 | return nil; 37 | } 38 | 39 | // 第三步,返回方法签名。如果返回nil,则表示无法处理消息 调用-doesNotRecognizeSelector 40 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { 41 | if ([NSStringFromSelector(aSelector) isEqualToString:@"dynamicMehod"]) { 42 | return [NSMethodSignature signatureWithObjCTypes:"v@:"]; 43 | } 44 | 45 | return [super methodSignatureForSelector:aSelector]; 46 | } 47 | 48 | // 第四步,返回了方法签名,都会进入这一步,这一步用户调用方法 49 | // 改变调用对象等 50 | // 当我们实现了此方法后,-doesNotRecognizeSelector:不会再被调用 51 | // 如果要测试找不到方法,可以注释掉这一个方法 52 | - (void)forwardInvocation:(NSInvocation *)anInvocation { 53 | 54 | // 我们还可以改变方法选择器 55 | [anInvocation setSelector:@selector(wxsMethod)]; 56 | // 改变方法选择器后,还需要指定是哪个对象的方法 57 | [anInvocation invokeWithTarget:self]; 58 | } 59 | 60 | - (void)doesNotRecognizeSelector:(SEL)aSelector { 61 | NSLog(@"无法处理消息:%@", NSStringFromSelector(aSelector)); 62 | } 63 | 64 | - (void)wxsMethod { 65 | NSLog(@"dynamicMehod -> wxsMethodwxsMethod"); 66 | } 67 | 68 | + (void)test { 69 | 70 | WXSMessage *message = [[WXSMessage alloc] init]; 71 | [message dynamicMehod]; 72 | 73 | 74 | } 75 | 76 | 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /WXSRuntime/WXSMethod.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXSMethod.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/22. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | @interface WXSMethod : NSObject 13 | +(void)forTest; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /WXSRuntime/WXSMethod.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSMethod.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/22. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "WXSMethod.h" 10 | 11 | @implementation WXSMethod 12 | 13 | 14 | 15 | -(void)methodWithoutReturnAndArgument{ 16 | NSLog(@"methodWithoutReturnAndArgument"); 17 | } 18 | -(NSUInteger)methodWithIntAndArgument:(NSString*)test{ 19 | 20 | return test.length; 21 | 22 | } 23 | -(NSMutableArray *)arraymethodArray:(NSString *)key { 24 | NSMutableArray *arry =[[NSMutableArray alloc] init]; 25 | for (int i = 0; i < key.length; i ++) { 26 | NSString *t = [key substringWithRange:NSMakeRange(i, 1)]; 27 | [arry addObject:t]; 28 | } 29 | return arry; 30 | 31 | } 32 | -(void)logMethods { 33 | unsigned int outCount = 0; 34 | Method *methods = class_copyMethodList(self.class, &outCount); 35 | for (int i = 0; i < outCount; i++) { 36 | 37 | Method method = methods[i]; 38 | SEL nameSel = method_getName(method); 39 | 40 | const char *type = method_getTypeEncoding(method); 41 | NSString *typeStr = [NSString stringWithUTF8String:type]; 42 | 43 | char returnType[256] = {}; 44 | method_getReturnType(method, returnType, 256); 45 | NSString *returnTypeStr = [NSString stringWithUTF8String:returnType]; 46 | 47 | NSLog(@"name : %@ |type : (%@) |returyType:(%@)| ",NSStringFromSelector(nameSel),typeStr,returnTypeStr); 48 | 49 | /* 50 | Q - NSUInteger 51 | q - NSInteger 52 | v - void 53 | i - int 54 | @ - OC类,包括NSString , NSArray , id等 55 | : - SEL 56 | 57 | */ 58 | 59 | } 60 | free(methods); 61 | 62 | } 63 | +(void)forTest{ 64 | WXSMethod *demo = [[WXSMethod alloc] init]; 65 | ((void (*)(id,SEL))objc_msgSend)((id)demo,@selector(logMethods)); 66 | 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /WXSRuntime/WXSModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXSModel.h 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import 12 | #import 13 | 14 | @interface WXSModel : NSObject 15 | 16 | -(instancetype)init UNAVAILABLE_ATTRIBUTE; 17 | -(instancetype)initWithDic:(NSDictionary *)dict; 18 | 19 | -(void)creatModelWithDic:(NSDictionary *)dict ; 20 | 21 | 22 | -(NSDictionary *)modelToDic; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /WXSRuntime/WXSModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSModel.m 3 | // WXSRuntime 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import "WXSModel.h" 10 | 11 | @implementation WXSModel 12 | 13 | 14 | -(instancetype)initWithDic:(NSDictionary *)dict { 15 | self = [super init]; 16 | if (self) { 17 | [self creatModelWithDic:dict]; 18 | } 19 | return self; 20 | } 21 | 22 | 23 | -(void)creatModelWithDic:(NSDictionary *)dict { 24 | 25 | // for (NSString *key in dict) { 26 | // 27 | // SEL setterSel = [self creatSetterWithKey:key]; 28 | // id value = dict[key]; 29 | // 30 | // if (setterSel != nil) { 31 | // ((void (*)(id,SEL,id))objc_msgSend)(self,setterSel,value); 32 | // } 33 | // } 34 | // 35 | 36 | 37 | // unsigned int outCount = 0; 38 | // Ivar *ivars = class_copyIvarList(self.class, &outCount); 39 | // for (int i = 0; i < outCount; i++) { 40 | // 41 | // Ivar ivar = ivars[i]; 42 | // const char *typeC = ivar_getTypeEncoding(ivar); 43 | // NSString *type = [NSString stringWithUTF8String:typeC]; 44 | // 45 | // const char *nameC = ivar_getName(ivar); 46 | // NSString *name = [NSString stringWithUTF8String:nameC]; 47 | // NSLog(@"type %@ name %@",type,name); 48 | // 49 | // } 50 | 51 | 52 | unsigned int outCount = 0; 53 | objc_property_t *properties = class_copyPropertyList(self.class, &outCount); 54 | for (int i = 0; i < outCount; i++) { 55 | objc_property_t property = properties[i]; 56 | const char *propertyName = property_getName(property); 57 | NSString *key = [NSString stringWithUTF8String:propertyName]; 58 | 59 | id value = nil; 60 | 61 | if (![dict[key] isKindOfClass:[NSNull class]]) { 62 | value = dict[key]; 63 | } 64 | 65 | unsigned int count = 0; 66 | objc_property_attribute_t *atts = property_copyAttributeList(property, &count); 67 | objc_property_attribute_t att = atts[0]; 68 | NSString *type = [NSString stringWithUTF8String:att.value]; 69 | type = [type stringByReplacingOccurrencesOfString:@"“" withString:@""]; 70 | type = [type stringByReplacingOccurrencesOfString:@"@" withString:@""]; 71 | 72 | NSLog(@"type%@",type); 73 | 74 | //数据为数组时 75 | if ([value isKindOfClass:[NSArray class]]) { 76 | Class class = NSClassFromString(key); 77 | NSMutableArray *temArr = [[NSMutableArray alloc] init]; 78 | for (NSDictionary *tempDic in value) { 79 | if (class) { 80 | id model = [[class alloc] initWithDic:tempDic]; 81 | [temArr addObject:model]; 82 | } 83 | } 84 | value = temArr; 85 | } 86 | 87 | //数据为字典时 88 | if ([value isKindOfClass:[NSDictionary class]] && ![type hasPrefix:@"NS"] ) { 89 | Class class = NSClassFromString(key); 90 | if (class) { 91 | value = [[class alloc] initWithDic:value]; 92 | } 93 | 94 | } 95 | 96 | // 赋值 97 | SEL setterSel = [self creatSetterWithKey:key]; 98 | if (setterSel != nil) { 99 | ((void (*)(id,SEL,id))objc_msgSend)(self,setterSel,value); 100 | } 101 | 102 | } 103 | } 104 | 105 | -(NSDictionary *)modelToDic { 106 | 107 | NSMutableDictionary *dic = [[NSMutableDictionary alloc] init]; 108 | 109 | unsigned int outCount = 0; 110 | objc_property_t *properties = class_copyPropertyList(self.class, &outCount); 111 | for (int i = 0; i < outCount; i++) { 112 | objc_property_t property = properties[i]; 113 | const char *pName = property_getName(property); 114 | NSString *key = [NSString stringWithUTF8String:pName]; 115 | 116 | SEL getter = [self creatGetterWithKey:key]; 117 | 118 | if (getter) { 119 | 120 | //有几种方式获得value 121 | 122 | // id value = [self performSelector:getter]; 123 | 124 | // id value = [self valueForKey:key]; 125 | 126 | 127 | // NSMethodSignature *signature = [self methodSignatureForSelector:getter]; 128 | // NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 129 | // [invocation setSelector:getter]; 130 | // [invocation invokeWithTarget:self]; 131 | // __unsafe_unretained NSObject *value = nil; 132 | // [invocation getReturnValue:&value]; 133 | 134 | 135 | id value = ((id (*)(id,SEL))objc_msgSend)(self,getter); 136 | 137 | if (value == nil) { 138 | 139 | unsigned int outCount = 0; 140 | 141 | objc_property_attribute_t *attributes = property_copyAttributeList(property, &outCount); 142 | for (int i = 0; i 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 | -------------------------------------------------------------------------------- /WXSRuntimeTests/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 | -------------------------------------------------------------------------------- /WXSRuntimeTests/WXSRuntimeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSRuntimeTests.m 3 | // WXSRuntimeTests 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WXSRuntimeTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WXSRuntimeTests 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 | -------------------------------------------------------------------------------- /WXSRuntimeUITests/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 | -------------------------------------------------------------------------------- /WXSRuntimeUITests/WXSRuntimeUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXSRuntimeUITests.m 3 | // WXSRuntimeUITests 4 | // 5 | // Created by 王小树 on 16/4/18. 6 | // Copyright © 2016年 王小树. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WXSRuntimeUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WXSRuntimeUITests 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 | --------------------------------------------------------------------------------