├── 数组越界.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── mic.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── mic.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── 数组越界 ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── NextVC.h ├── NextVC.m ├── ViewController.h ├── ViewController.m └── main.m ├── 数组越界Tests ├── Info.plist └── ____Tests.m ├── 数组越界UITests ├── Info.plist └── ____UITests.m └── 添加分类 ├── NSArray+ErrorHandle.h ├── NSArray+ErrorHandle.m ├── NSMutableArray+ErrorHandle.h ├── NSMutableArray+ErrorHandle.m ├── NSObject+SwizzleMethod.h └── NSObject+SwizzleMethod.m /数组越界.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 052A8E5F1FF6463A0087CD3F /* NSObject+SwizzleMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = 052A8E5E1FF6463A0087CD3F /* NSObject+SwizzleMethod.m */; }; 11 | 053517391FF24ECD00533702 /* NSMutableArray+ErrorHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = 053517381FF24ECD00533702 /* NSMutableArray+ErrorHandle.m */; }; 12 | 054825811FF1E47900B6FDE3 /* NextVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 054825801FF1E47900B6FDE3 /* NextVC.m */; }; 13 | 054825991FF1F16F00B6FDE3 /* NSArray+ErrorHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = 054825971FF1F16F00B6FDE3 /* NSArray+ErrorHandle.m */; }; 14 | 0574AB071FF118660002CC41 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0574AB061FF118660002CC41 /* AppDelegate.m */; }; 15 | 0574AB0A1FF118660002CC41 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0574AB091FF118660002CC41 /* ViewController.m */; }; 16 | 0574AB0D1FF118660002CC41 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0574AB0B1FF118660002CC41 /* Main.storyboard */; }; 17 | 0574AB0F1FF118670002CC41 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0574AB0E1FF118670002CC41 /* Assets.xcassets */; }; 18 | 0574AB121FF118670002CC41 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0574AB101FF118670002CC41 /* LaunchScreen.storyboard */; }; 19 | 0574AB151FF118670002CC41 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0574AB141FF118670002CC41 /* main.m */; }; 20 | 0574AB1F1FF118670002CC41 /* ____Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0574AB1E1FF118670002CC41 /* ____Tests.m */; }; 21 | 0574AB2A1FF118670002CC41 /* ____UITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0574AB291FF118670002CC41 /* ____UITests.m */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | 0574AB1B1FF118670002CC41 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = 0574AAFA1FF118660002CC41 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = 0574AB011FF118660002CC41; 30 | remoteInfo = "数组越界"; 31 | }; 32 | 0574AB261FF118670002CC41 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 0574AAFA1FF118660002CC41 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 0574AB011FF118660002CC41; 37 | remoteInfo = "数组越界"; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 052A8E5D1FF6463A0087CD3F /* NSObject+SwizzleMethod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+SwizzleMethod.h"; sourceTree = ""; }; 43 | 052A8E5E1FF6463A0087CD3F /* NSObject+SwizzleMethod.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+SwizzleMethod.m"; sourceTree = ""; }; 44 | 053517371FF24ECD00533702 /* NSMutableArray+ErrorHandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+ErrorHandle.h"; sourceTree = ""; }; 45 | 053517381FF24ECD00533702 /* NSMutableArray+ErrorHandle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableArray+ErrorHandle.m"; sourceTree = ""; }; 46 | 0548257F1FF1E47900B6FDE3 /* NextVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NextVC.h; sourceTree = ""; }; 47 | 054825801FF1E47900B6FDE3 /* NextVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NextVC.m; sourceTree = ""; }; 48 | 054825951FF1F16E00B6FDE3 /* NSArray+ErrorHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+ErrorHandle.h"; sourceTree = ""; }; 49 | 054825971FF1F16F00B6FDE3 /* NSArray+ErrorHandle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+ErrorHandle.m"; sourceTree = ""; }; 50 | 0574AB021FF118660002CC41 /* 数组越界.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "数组越界.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 0574AB051FF118660002CC41 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 52 | 0574AB061FF118660002CC41 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 53 | 0574AB081FF118660002CC41 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 54 | 0574AB091FF118660002CC41 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 55 | 0574AB0C1FF118660002CC41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | 0574AB0E1FF118670002CC41 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 57 | 0574AB111FF118670002CC41 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 58 | 0574AB131FF118670002CC41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | 0574AB141FF118670002CC41 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 60 | 0574AB1A1FF118670002CC41 /* 数组越界Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "数组越界Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 0574AB1E1FF118670002CC41 /* ____Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "____Tests.m"; sourceTree = ""; }; 62 | 0574AB201FF118670002CC41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | 0574AB251FF118670002CC41 /* 数组越界UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "数组越界UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 0574AB291FF118670002CC41 /* ____UITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "____UITests.m"; sourceTree = ""; }; 65 | 0574AB2B1FF118670002CC41 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | /* End PBXFileReference section */ 67 | 68 | /* Begin PBXFrameworksBuildPhase section */ 69 | 0574AAFF1FF118660002CC41 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 0574AB171FF118670002CC41 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | 0574AB221FF118670002CC41 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | /* End PBXFrameworksBuildPhase section */ 91 | 92 | /* Begin PBXGroup section */ 93 | 053517301FF2246C00533702 /* 添加分类 */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 054825951FF1F16E00B6FDE3 /* NSArray+ErrorHandle.h */, 97 | 054825971FF1F16F00B6FDE3 /* NSArray+ErrorHandle.m */, 98 | 053517371FF24ECD00533702 /* NSMutableArray+ErrorHandle.h */, 99 | 053517381FF24ECD00533702 /* NSMutableArray+ErrorHandle.m */, 100 | 052A8E5D1FF6463A0087CD3F /* NSObject+SwizzleMethod.h */, 101 | 052A8E5E1FF6463A0087CD3F /* NSObject+SwizzleMethod.m */, 102 | ); 103 | path = "添加分类"; 104 | sourceTree = ""; 105 | }; 106 | 0574AAF91FF118660002CC41 = { 107 | isa = PBXGroup; 108 | children = ( 109 | 053517301FF2246C00533702 /* 添加分类 */, 110 | 0574AB041FF118660002CC41 /* 数组越界 */, 111 | 0574AB1D1FF118670002CC41 /* 数组越界Tests */, 112 | 0574AB281FF118670002CC41 /* 数组越界UITests */, 113 | 0574AB031FF118660002CC41 /* Products */, 114 | ); 115 | sourceTree = ""; 116 | }; 117 | 0574AB031FF118660002CC41 /* Products */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 0574AB021FF118660002CC41 /* 数组越界.app */, 121 | 0574AB1A1FF118670002CC41 /* 数组越界Tests.xctest */, 122 | 0574AB251FF118670002CC41 /* 数组越界UITests.xctest */, 123 | ); 124 | name = Products; 125 | sourceTree = ""; 126 | }; 127 | 0574AB041FF118660002CC41 /* 数组越界 */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 0574AB051FF118660002CC41 /* AppDelegate.h */, 131 | 0574AB061FF118660002CC41 /* AppDelegate.m */, 132 | 0574AB081FF118660002CC41 /* ViewController.h */, 133 | 0574AB091FF118660002CC41 /* ViewController.m */, 134 | 0548257F1FF1E47900B6FDE3 /* NextVC.h */, 135 | 054825801FF1E47900B6FDE3 /* NextVC.m */, 136 | 0574AB0B1FF118660002CC41 /* Main.storyboard */, 137 | 0574AB0E1FF118670002CC41 /* Assets.xcassets */, 138 | 0574AB101FF118670002CC41 /* LaunchScreen.storyboard */, 139 | 0574AB131FF118670002CC41 /* Info.plist */, 140 | 0574AB141FF118670002CC41 /* main.m */, 141 | ); 142 | path = "数组越界"; 143 | sourceTree = ""; 144 | }; 145 | 0574AB1D1FF118670002CC41 /* 数组越界Tests */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 0574AB1E1FF118670002CC41 /* ____Tests.m */, 149 | 0574AB201FF118670002CC41 /* Info.plist */, 150 | ); 151 | path = "数组越界Tests"; 152 | sourceTree = ""; 153 | }; 154 | 0574AB281FF118670002CC41 /* 数组越界UITests */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 0574AB291FF118670002CC41 /* ____UITests.m */, 158 | 0574AB2B1FF118670002CC41 /* Info.plist */, 159 | ); 160 | path = "数组越界UITests"; 161 | sourceTree = ""; 162 | }; 163 | /* End PBXGroup section */ 164 | 165 | /* Begin PBXNativeTarget section */ 166 | 0574AB011FF118660002CC41 /* 数组越界 */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = 0574AB2E1FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界" */; 169 | buildPhases = ( 170 | 0574AAFE1FF118660002CC41 /* Sources */, 171 | 0574AAFF1FF118660002CC41 /* Frameworks */, 172 | 0574AB001FF118660002CC41 /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | ); 178 | name = "数组越界"; 179 | productName = "数组越界"; 180 | productReference = 0574AB021FF118660002CC41 /* 数组越界.app */; 181 | productType = "com.apple.product-type.application"; 182 | }; 183 | 0574AB191FF118670002CC41 /* 数组越界Tests */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = 0574AB311FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界Tests" */; 186 | buildPhases = ( 187 | 0574AB161FF118670002CC41 /* Sources */, 188 | 0574AB171FF118670002CC41 /* Frameworks */, 189 | 0574AB181FF118670002CC41 /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | 0574AB1C1FF118670002CC41 /* PBXTargetDependency */, 195 | ); 196 | name = "数组越界Tests"; 197 | productName = "数组越界Tests"; 198 | productReference = 0574AB1A1FF118670002CC41 /* 数组越界Tests.xctest */; 199 | productType = "com.apple.product-type.bundle.unit-test"; 200 | }; 201 | 0574AB241FF118670002CC41 /* 数组越界UITests */ = { 202 | isa = PBXNativeTarget; 203 | buildConfigurationList = 0574AB341FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界UITests" */; 204 | buildPhases = ( 205 | 0574AB211FF118670002CC41 /* Sources */, 206 | 0574AB221FF118670002CC41 /* Frameworks */, 207 | 0574AB231FF118670002CC41 /* Resources */, 208 | ); 209 | buildRules = ( 210 | ); 211 | dependencies = ( 212 | 0574AB271FF118670002CC41 /* PBXTargetDependency */, 213 | ); 214 | name = "数组越界UITests"; 215 | productName = "数组越界UITests"; 216 | productReference = 0574AB251FF118670002CC41 /* 数组越界UITests.xctest */; 217 | productType = "com.apple.product-type.bundle.ui-testing"; 218 | }; 219 | /* End PBXNativeTarget section */ 220 | 221 | /* Begin PBXProject section */ 222 | 0574AAFA1FF118660002CC41 /* Project object */ = { 223 | isa = PBXProject; 224 | attributes = { 225 | LastUpgradeCheck = 0920; 226 | ORGANIZATIONNAME = JZ; 227 | TargetAttributes = { 228 | 0574AB011FF118660002CC41 = { 229 | CreatedOnToolsVersion = 9.2; 230 | ProvisioningStyle = Automatic; 231 | }; 232 | 0574AB191FF118670002CC41 = { 233 | CreatedOnToolsVersion = 9.2; 234 | ProvisioningStyle = Automatic; 235 | TestTargetID = 0574AB011FF118660002CC41; 236 | }; 237 | 0574AB241FF118670002CC41 = { 238 | CreatedOnToolsVersion = 9.2; 239 | ProvisioningStyle = Automatic; 240 | TestTargetID = 0574AB011FF118660002CC41; 241 | }; 242 | }; 243 | }; 244 | buildConfigurationList = 0574AAFD1FF118660002CC41 /* Build configuration list for PBXProject "数组越界" */; 245 | compatibilityVersion = "Xcode 8.0"; 246 | developmentRegion = en; 247 | hasScannedForEncodings = 0; 248 | knownRegions = ( 249 | en, 250 | Base, 251 | ); 252 | mainGroup = 0574AAF91FF118660002CC41; 253 | productRefGroup = 0574AB031FF118660002CC41 /* Products */; 254 | projectDirPath = ""; 255 | projectRoot = ""; 256 | targets = ( 257 | 0574AB011FF118660002CC41 /* 数组越界 */, 258 | 0574AB191FF118670002CC41 /* 数组越界Tests */, 259 | 0574AB241FF118670002CC41 /* 数组越界UITests */, 260 | ); 261 | }; 262 | /* End PBXProject section */ 263 | 264 | /* Begin PBXResourcesBuildPhase section */ 265 | 0574AB001FF118660002CC41 /* Resources */ = { 266 | isa = PBXResourcesBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | 0574AB121FF118670002CC41 /* LaunchScreen.storyboard in Resources */, 270 | 0574AB0F1FF118670002CC41 /* Assets.xcassets in Resources */, 271 | 0574AB0D1FF118660002CC41 /* Main.storyboard in Resources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | 0574AB181FF118670002CC41 /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | 0574AB231FF118670002CC41 /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | /* End PBXResourcesBuildPhase section */ 290 | 291 | /* Begin PBXSourcesBuildPhase section */ 292 | 0574AAFE1FF118660002CC41 /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | 053517391FF24ECD00533702 /* NSMutableArray+ErrorHandle.m in Sources */, 297 | 0574AB0A1FF118660002CC41 /* ViewController.m in Sources */, 298 | 052A8E5F1FF6463A0087CD3F /* NSObject+SwizzleMethod.m in Sources */, 299 | 0574AB151FF118670002CC41 /* main.m in Sources */, 300 | 0574AB071FF118660002CC41 /* AppDelegate.m in Sources */, 301 | 054825991FF1F16F00B6FDE3 /* NSArray+ErrorHandle.m in Sources */, 302 | 054825811FF1E47900B6FDE3 /* NextVC.m in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | 0574AB161FF118670002CC41 /* Sources */ = { 307 | isa = PBXSourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | 0574AB1F1FF118670002CC41 /* ____Tests.m in Sources */, 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | }; 314 | 0574AB211FF118670002CC41 /* Sources */ = { 315 | isa = PBXSourcesBuildPhase; 316 | buildActionMask = 2147483647; 317 | files = ( 318 | 0574AB2A1FF118670002CC41 /* ____UITests.m in Sources */, 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | /* End PBXSourcesBuildPhase section */ 323 | 324 | /* Begin PBXTargetDependency section */ 325 | 0574AB1C1FF118670002CC41 /* PBXTargetDependency */ = { 326 | isa = PBXTargetDependency; 327 | target = 0574AB011FF118660002CC41 /* 数组越界 */; 328 | targetProxy = 0574AB1B1FF118670002CC41 /* PBXContainerItemProxy */; 329 | }; 330 | 0574AB271FF118670002CC41 /* PBXTargetDependency */ = { 331 | isa = PBXTargetDependency; 332 | target = 0574AB011FF118660002CC41 /* 数组越界 */; 333 | targetProxy = 0574AB261FF118670002CC41 /* PBXContainerItemProxy */; 334 | }; 335 | /* End PBXTargetDependency section */ 336 | 337 | /* Begin PBXVariantGroup section */ 338 | 0574AB0B1FF118660002CC41 /* Main.storyboard */ = { 339 | isa = PBXVariantGroup; 340 | children = ( 341 | 0574AB0C1FF118660002CC41 /* Base */, 342 | ); 343 | name = Main.storyboard; 344 | sourceTree = ""; 345 | }; 346 | 0574AB101FF118670002CC41 /* LaunchScreen.storyboard */ = { 347 | isa = PBXVariantGroup; 348 | children = ( 349 | 0574AB111FF118670002CC41 /* Base */, 350 | ); 351 | name = LaunchScreen.storyboard; 352 | sourceTree = ""; 353 | }; 354 | /* End PBXVariantGroup section */ 355 | 356 | /* Begin XCBuildConfiguration section */ 357 | 0574AB2C1FF118670002CC41 /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ALWAYS_SEARCH_USER_PATHS = NO; 361 | CLANG_ANALYZER_NONNULL = YES; 362 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 363 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 364 | CLANG_CXX_LIBRARY = "libc++"; 365 | CLANG_ENABLE_MODULES = YES; 366 | CLANG_ENABLE_OBJC_ARC = YES; 367 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 368 | CLANG_WARN_BOOL_CONVERSION = YES; 369 | CLANG_WARN_COMMA = YES; 370 | CLANG_WARN_CONSTANT_CONVERSION = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 373 | CLANG_WARN_EMPTY_BODY = YES; 374 | CLANG_WARN_ENUM_CONVERSION = YES; 375 | CLANG_WARN_INFINITE_RECURSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 378 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 379 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 380 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 381 | CLANG_WARN_STRICT_PROTOTYPES = YES; 382 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 383 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 384 | CLANG_WARN_UNREACHABLE_CODE = YES; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | CODE_SIGN_IDENTITY = "iPhone Developer"; 387 | COPY_PHASE_STRIP = NO; 388 | DEBUG_INFORMATION_FORMAT = dwarf; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | ENABLE_TESTABILITY = YES; 391 | GCC_C_LANGUAGE_STANDARD = gnu11; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_NO_COMMON_BLOCKS = YES; 394 | GCC_OPTIMIZATION_LEVEL = 0; 395 | GCC_PREPROCESSOR_DEFINITIONS = ( 396 | "DEBUG=1", 397 | "$(inherited)", 398 | ); 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 406 | MTL_ENABLE_DEBUG_INFO = YES; 407 | ONLY_ACTIVE_ARCH = YES; 408 | SDKROOT = iphoneos; 409 | }; 410 | name = Debug; 411 | }; 412 | 0574AB2D1FF118670002CC41 /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | CLANG_ANALYZER_NONNULL = YES; 417 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 418 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 419 | CLANG_CXX_LIBRARY = "libc++"; 420 | CLANG_ENABLE_MODULES = YES; 421 | CLANG_ENABLE_OBJC_ARC = YES; 422 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 423 | CLANG_WARN_BOOL_CONVERSION = YES; 424 | CLANG_WARN_COMMA = YES; 425 | CLANG_WARN_CONSTANT_CONVERSION = YES; 426 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 427 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 428 | CLANG_WARN_EMPTY_BODY = YES; 429 | CLANG_WARN_ENUM_CONVERSION = YES; 430 | CLANG_WARN_INFINITE_RECURSION = YES; 431 | CLANG_WARN_INT_CONVERSION = YES; 432 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 433 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 434 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 435 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 436 | CLANG_WARN_STRICT_PROTOTYPES = YES; 437 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 438 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 439 | CLANG_WARN_UNREACHABLE_CODE = YES; 440 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 441 | CODE_SIGN_IDENTITY = "iPhone Developer"; 442 | COPY_PHASE_STRIP = NO; 443 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 444 | ENABLE_NS_ASSERTIONS = NO; 445 | ENABLE_STRICT_OBJC_MSGSEND = YES; 446 | GCC_C_LANGUAGE_STANDARD = gnu11; 447 | GCC_NO_COMMON_BLOCKS = YES; 448 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 449 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 450 | GCC_WARN_UNDECLARED_SELECTOR = YES; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | GCC_WARN_UNUSED_FUNCTION = YES; 453 | GCC_WARN_UNUSED_VARIABLE = YES; 454 | IPHONEOS_DEPLOYMENT_TARGET = 11.2; 455 | MTL_ENABLE_DEBUG_INFO = NO; 456 | SDKROOT = iphoneos; 457 | VALIDATE_PRODUCT = YES; 458 | }; 459 | name = Release; 460 | }; 461 | 0574AB2F1FF118670002CC41 /* Debug */ = { 462 | isa = XCBuildConfiguration; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | CODE_SIGN_STYLE = Automatic; 466 | DEVELOPMENT_TEAM = 4N4MLS3Q46; 467 | INFOPLIST_FILE = "数组越界/Info.plist"; 468 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 469 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 470 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----"; 471 | PRODUCT_NAME = "$(TARGET_NAME)"; 472 | TARGETED_DEVICE_FAMILY = "1,2"; 473 | }; 474 | name = Debug; 475 | }; 476 | 0574AB301FF118670002CC41 /* Release */ = { 477 | isa = XCBuildConfiguration; 478 | buildSettings = { 479 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 480 | CODE_SIGN_STYLE = Automatic; 481 | DEVELOPMENT_TEAM = 4N4MLS3Q46; 482 | INFOPLIST_FILE = "数组越界/Info.plist"; 483 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 484 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 485 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----"; 486 | PRODUCT_NAME = "$(TARGET_NAME)"; 487 | TARGETED_DEVICE_FAMILY = "1,2"; 488 | }; 489 | name = Release; 490 | }; 491 | 0574AB321FF118670002CC41 /* Debug */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | BUNDLE_LOADER = "$(TEST_HOST)"; 495 | CODE_SIGN_STYLE = Automatic; 496 | INFOPLIST_FILE = "数组越界Tests/Info.plist"; 497 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 498 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----Tests"; 499 | PRODUCT_NAME = "$(TARGET_NAME)"; 500 | TARGETED_DEVICE_FAMILY = "1,2"; 501 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/数组越界.app/数组越界"; 502 | }; 503 | name = Debug; 504 | }; 505 | 0574AB331FF118670002CC41 /* Release */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | BUNDLE_LOADER = "$(TEST_HOST)"; 509 | CODE_SIGN_STYLE = Automatic; 510 | INFOPLIST_FILE = "数组越界Tests/Info.plist"; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----Tests"; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TARGETED_DEVICE_FAMILY = "1,2"; 515 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/数组越界.app/数组越界"; 516 | }; 517 | name = Release; 518 | }; 519 | 0574AB351FF118670002CC41 /* Debug */ = { 520 | isa = XCBuildConfiguration; 521 | buildSettings = { 522 | CODE_SIGN_STYLE = Automatic; 523 | INFOPLIST_FILE = "数组越界UITests/Info.plist"; 524 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 525 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----UITests"; 526 | PRODUCT_NAME = "$(TARGET_NAME)"; 527 | TARGETED_DEVICE_FAMILY = "1,2"; 528 | TEST_TARGET_NAME = "数组越界"; 529 | }; 530 | name = Debug; 531 | }; 532 | 0574AB361FF118670002CC41 /* Release */ = { 533 | isa = XCBuildConfiguration; 534 | buildSettings = { 535 | CODE_SIGN_STYLE = Automatic; 536 | INFOPLIST_FILE = "数组越界UITests/Info.plist"; 537 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 538 | PRODUCT_BUNDLE_IDENTIFIER = "JZ.----UITests"; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | TARGETED_DEVICE_FAMILY = "1,2"; 541 | TEST_TARGET_NAME = "数组越界"; 542 | }; 543 | name = Release; 544 | }; 545 | /* End XCBuildConfiguration section */ 546 | 547 | /* Begin XCConfigurationList section */ 548 | 0574AAFD1FF118660002CC41 /* Build configuration list for PBXProject "数组越界" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | 0574AB2C1FF118670002CC41 /* Debug */, 552 | 0574AB2D1FF118670002CC41 /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | 0574AB2E1FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界" */ = { 558 | isa = XCConfigurationList; 559 | buildConfigurations = ( 560 | 0574AB2F1FF118670002CC41 /* Debug */, 561 | 0574AB301FF118670002CC41 /* Release */, 562 | ); 563 | defaultConfigurationIsVisible = 0; 564 | defaultConfigurationName = Release; 565 | }; 566 | 0574AB311FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界Tests" */ = { 567 | isa = XCConfigurationList; 568 | buildConfigurations = ( 569 | 0574AB321FF118670002CC41 /* Debug */, 570 | 0574AB331FF118670002CC41 /* Release */, 571 | ); 572 | defaultConfigurationIsVisible = 0; 573 | defaultConfigurationName = Release; 574 | }; 575 | 0574AB341FF118670002CC41 /* Build configuration list for PBXNativeTarget "数组越界UITests" */ = { 576 | isa = XCConfigurationList; 577 | buildConfigurations = ( 578 | 0574AB351FF118670002CC41 /* Debug */, 579 | 0574AB361FF118670002CC41 /* Release */, 580 | ); 581 | defaultConfigurationIsVisible = 0; 582 | defaultConfigurationName = Release; 583 | }; 584 | /* End XCConfigurationList section */ 585 | }; 586 | rootObject = 0574AAFA1FF118660002CC41 /* Project object */; 587 | } 588 | -------------------------------------------------------------------------------- /数组越界.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /数组越界.xcodeproj/project.xcworkspace/xcuserdata/mic.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FreeMusic/ArrayBounds/606d2bbbed3b0797950f67249b654b10858df31a/数组越界.xcodeproj/project.xcworkspace/xcuserdata/mic.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /数组越界.xcodeproj/xcuserdata/mic.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 30 | 31 | 32 | 34 | 46 | 47 | 48 | 50 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /数组越界.xcodeproj/xcuserdata/mic.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 数组越界.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /数组越界/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. 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 | -------------------------------------------------------------------------------- /数组越界/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | return YES; 22 | } 23 | 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application { 26 | // 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. 27 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 28 | } 29 | 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application { 32 | // 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. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application { 38 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application { 43 | // 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. 44 | } 45 | 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /数组越界/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /数组越界/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 | -------------------------------------------------------------------------------- /数组越界/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 | -------------------------------------------------------------------------------- /数组越界/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /数组越界/NextVC.h: -------------------------------------------------------------------------------- 1 | // 2 | // NextVC.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/26. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NextVC : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /数组越界/NextVC.m: -------------------------------------------------------------------------------- 1 | // 2 | // NextVC.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/26. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "NSArray+ErrorHandle.h" 10 | #import "NextVC.h" 11 | #import "NSMutableArray+ErrorHandle.h" 12 | 13 | /** 14 | * 屏幕尺寸宽和高 15 | */ 16 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 17 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 18 | 19 | @interface NextVC () 20 | 21 | @property (nonatomic, strong) UITableView *tableView; 22 | 23 | @property (nonatomic, strong) NSArray *dataSource; 24 | 25 | @end 26 | 27 | @implementation NextVC 28 | 29 | - (void)viewDidLoad { 30 | [super viewDidLoad]; 31 | 32 | self.dataSource = [NSArray arrayWithObjects:@"语文", @"数学", @"英语", nil]; 33 | [self.view addSubview:self.tableView]; 34 | } 35 | /** 36 | *tableView的懒加载 37 | */ 38 | - (UITableView *)tableView{ 39 | if(!_tableView){ 40 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)]; 41 | 42 | _tableView.delegate = self; 43 | _tableView.dataSource = self; 44 | 45 | _tableView.tableFooterView = [UIView new]; 46 | _tableView.showsVerticalScrollIndicator = NO; 47 | _tableView.showsHorizontalScrollIndicator = NO; 48 | } 49 | return _tableView; 50 | } 51 | 52 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 53 | return 5; 54 | } 55 | #pragma mark - cellForRowAtIndexPath 56 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 57 | NSString *str = @"UITableViewCell"; 58 | 59 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str]; 60 | 61 | if (!cell) { 62 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str]; 63 | if (indexPath.row < self.dataSource.count) { 64 | UITextField *textFiled = [[UITextField alloc] init]; 65 | textFiled.frame = CGRectMake(100, 0, kScreenWidth-100, 50); 66 | textFiled.placeholder = @"此处是NSArray的数组越界处理"; 67 | [cell addSubview:textFiled]; 68 | }else{ 69 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 50)]; 70 | label.textColor = [UIColor blackColor]; 71 | label.text = @"点击此处去查看NSMutableArray的数组越界处理"; 72 | [cell addSubview:label]; 73 | } 74 | } 75 | cell.textLabel.text = self.dataSource[indexPath.row]; 76 | 77 | return cell; 78 | } 79 | 80 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 81 | return 50; 82 | } 83 | 84 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 85 | [self dismissViewControllerAnimated:YES completion:^{ 86 | 87 | }]; 88 | } 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /数组越界/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /数组越界/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "NSArray+ErrorHandle.h" 11 | #import "NextVC.h" 12 | #import "NSMutableArray+ErrorHandle.h" 13 | 14 | /** 15 | * 屏幕尺寸宽和高 16 | */ 17 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 18 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 19 | 20 | @interface ViewController () 21 | 22 | @property (nonatomic, strong) UITableView *tableView; 23 | 24 | @property (nonatomic, strong) NSMutableArray *dataSource; 25 | 26 | @property (nonatomic, strong) NSArray *array; 27 | 28 | @end 29 | 30 | @implementation ViewController 31 | 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | // Do any additional setup after loading the view, typically from a nib. 35 | NSString *type = nil; 36 | self.array = [NSArray arrayWithObjects:@"语文", @"数学", @"英语", nil]; 37 | [self.dataSource addObjectVerify:type]; 38 | [self.dataSource addObjectVerify:@"语文"]; 39 | [self.dataSource addObjectVerify:@"数学"]; 40 | [self.dataSource addObjectVerify:@"英语"]; 41 | [self.dataSource insertObjectVerify:type atIndex:10]; 42 | [self.dataSource insertObjectVerify:@"物理" atIndex:2]; 43 | 44 | [self.view addSubview:self.tableView]; 45 | } 46 | /** 47 | * dataSource 48 | */ 49 | - (NSMutableArray *)dataSource{ 50 | if(!_dataSource){ 51 | _dataSource = [NSMutableArray array]; 52 | } 53 | return _dataSource; 54 | } 55 | /** 56 | *tableView的懒加载 57 | */ 58 | - (UITableView *)tableView{ 59 | if(!_tableView){ 60 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)]; 61 | 62 | _tableView.delegate = self; 63 | _tableView.dataSource = self; 64 | 65 | _tableView.tableFooterView = [UIView new]; 66 | _tableView.showsVerticalScrollIndicator = NO; 67 | _tableView.showsHorizontalScrollIndicator = NO; 68 | } 69 | return _tableView; 70 | } 71 | 72 | -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 73 | return self.dataSource.count+5; 74 | } 75 | #pragma mark - cellForRowAtIndexPath 76 | -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 77 | NSString *str = @"UITableViewCell"; 78 | 79 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str]; 80 | 81 | if (!cell) { 82 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str]; 83 | if (indexPath.row < self.dataSource.count) { 84 | UITextField *textFiled = [[UITextField alloc] init]; 85 | textFiled.frame = CGRectMake(70, 0, kScreenWidth-70, 50); 86 | textFiled.placeholder = @"此处是NSMutableArray的数组越界处理"; 87 | [cell addSubview:textFiled]; 88 | }else{ 89 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, kScreenWidth-30, 50)]; 90 | label.textColor = [UIColor blackColor]; 91 | label.text = @"点击此处去查看NSArray的数组越界处理"; 92 | [cell addSubview:label]; 93 | } 94 | } 95 | cell.textLabel.text = self.dataSource[indexPath.row]; 96 | //cell.textLabel.text = self.dataSource[indexPath.row]; 97 | //cell.textLabel.text = [self.dataSource objectAtIndexVerify:indexPath.row]; 98 | //cell.textLabel.text = [self.dataSource objectAtIndex:indexPath.row]; 99 | 100 | return cell; 101 | } 102 | 103 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ 104 | return 50; 105 | } 106 | 107 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 108 | NextVC *tempVC = [[NextVC alloc] init]; 109 | 110 | [self presentViewController:tempVC animated:YES completion:^{ 111 | 112 | }]; 113 | } 114 | 115 | - (void)didReceiveMemoryWarning { 116 | [super didReceiveMemoryWarning]; 117 | // Dispose of any resources that can be recreated. 118 | } 119 | 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /数组越界/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. 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 | -------------------------------------------------------------------------------- /数组越界Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /数组越界Tests/____Tests.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ : XCTestCase 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)setUp { 12 | [super setUp]; 13 | // Put setup code here. This method is called before the invocation of each test method in the class. 14 | } 15 | 16 | - (void)tearDown { 17 | // Put teardown code here. This method is called after the invocation of each test method in the class. 18 | [super tearDown]; 19 | } 20 | 21 | - (void)testExample { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | - (void)testPerformanceExample { 27 | // This is an example of a performance test case. 28 | [self measureBlock:^{ 29 | // Put the code you want to measure the time of here. 30 | }]; 31 | } 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /数组越界UITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /数组越界UITests/____UITests.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ : XCTestCase 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)setUp { 12 | [super setUp]; 13 | 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | 16 | // In UI tests it is usually best to stop immediately when a failure occurs. 17 | self.continueAfterFailure = NO; 18 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 19 | [[[XCUIApplication alloc] init] launch]; 20 | 21 | // 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. 22 | } 23 | 24 | - (void)tearDown { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample { 30 | // Use recording to get started writing UI tests. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /添加分类/NSArray+ErrorHandle.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+ErrorHandle.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (ErrorHandle) 12 | 13 | /** 14 | 为数组分类添加的方法 可以在应用中直接调用 可以防止数组越界导致的crash 15 | 16 | @param index 传入的取值下标 17 | @return id类型的数据 18 | */ 19 | - (id)objectAtIndexVerify:(NSUInteger)index; 20 | - (id)objectAtIndexedSubscriptVerify:(NSUInteger)idx; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /添加分类/NSArray+ErrorHandle.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+ErrorHandle.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/25. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "NSArray+ErrorHandle.h" 10 | #import 11 | #import "NSObject+SwizzleMethod.h" 12 | 13 | @implementation NSArray (ErrorHandle) 14 | /** 15 | * 防止数组越界 16 | */ 17 | - (id)objectAtIndexVerify:(NSUInteger)index{ 18 | if (index < self.count) { 19 | return [self objectAtIndex:index]; 20 | }else{ 21 | return nil; 22 | } 23 | } 24 | /** 25 | * 防止数组越界 26 | */ 27 | - (id)objectAtIndexedSubscriptVerify:(NSUInteger)idx{ 28 | if (idx < self.count) { 29 | return [self objectAtIndexedSubscript:idx]; 30 | }else{ 31 | return nil; 32 | } 33 | } 34 | 35 | +(void)load{ 36 | [super load]; 37 | //无论怎样 都要保证方法只交换一次 38 | static dispatch_once_t onceToken; 39 | dispatch_once(&onceToken, ^{ 40 | //交换NSArray中的objectAtIndex方法 41 | [objc_getClass("__NSArrayI") SystemSelector:@selector(objectAtIndex:) swizzledSelector:@selector(sxy_objectAtIndex:) error:nil]; 42 | //交换NSArray中的objectAtIndexedSubscript方法 43 | [objc_getClass("__NSArrayI") SystemSelector:@selector(objectAtIndexedSubscript:) swizzledSelector:@selector(sxy_objectAtIndexedSubscript:) error:nil]; 44 | }); 45 | } 46 | 47 | - (id)sxy_objectAtIndexedSubscript:(NSUInteger)idx{ 48 | if (idx < self.count) { 49 | return [self sxy_objectAtIndexedSubscript:idx]; 50 | }else{ 51 | NSLog(@" 你的 NSArray数组已经越界了 但是已经帮你处理好了 %ld %ld", idx, self.count); 52 | return nil; 53 | } 54 | } 55 | 56 | - (id)sxy_objectAtIndex:(NSUInteger)index{ 57 | if (index < self.count) { 58 | return [self sxy_objectAtIndex:index]; 59 | }else{ 60 | NSLog(@" 你的 NSArray数组已经越界了 但是已经帮你处理好了 %ld %ld", index, self.count); 61 | 62 | return nil; 63 | } 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /添加分类/NSMutableArray+ErrorHandle.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableArray+ErrorHandle.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/26. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSMutableArray (ErrorHandle) 12 | /** 13 | 数组中插入数据 14 | 15 | @param object 数据 16 | @param index 下标 17 | */ 18 | - (void)insertObjectVerify:(id)object atIndex:(NSInteger)index; 19 | /** 20 | 数组中添加数据 21 | 22 | @param object 数据 23 | */ 24 | - (void)addObjectVerify:(id)object; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /添加分类/NSMutableArray+ErrorHandle.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableArray+ErrorHandle.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/26. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "NSMutableArray+ErrorHandle.h" 10 | #import "NSObject+SwizzleMethod.h" 11 | #import 12 | 13 | @implementation NSMutableArray (ErrorHandle) 14 | /** 15 | * 数组中插入数据 16 | */ 17 | - (void)insertObjectVerify:(id)object atIndex:(NSInteger)index{ 18 | if (index < self.count && object) { 19 | [self insertObject:object atIndex:index]; 20 | } 21 | } 22 | /** 23 | * 数组中添加数据 24 | */ 25 | - (void)addObjectVerify:(id)object{ 26 | if (object) { 27 | [self addObject:object]; 28 | } 29 | } 30 | 31 | +(void)load{ 32 | [super load]; 33 | //无论怎样 都要保证方法只交换一次 34 | static dispatch_once_t onceToken; 35 | dispatch_once(&onceToken, ^{ 36 | //交换NSMutableArray中的方法 37 | [objc_getClass("__NSArrayM") SystemSelector:@selector(objectAtIndex:) swizzledSelector:@selector(jz_objectAtIndex:) error:nil]; 38 | //交换NSMutableArray中的方法 39 | [objc_getClass("__NSArrayM") SystemSelector:@selector(objectAtIndexedSubscript:) swizzledSelector:@selector(jz_objectAtIndexedSubscript:) error:nil]; 40 | }); 41 | } 42 | 43 | - (id)jz_objectAtIndex:(NSUInteger)index{ 44 | if (index < self.count) { 45 | return [self jz_objectAtIndex:index]; 46 | }else{ 47 | 48 | NSLog(@" 你的NSMutableArray数组已经越界 帮你处理好了%ld %ld %@", index, self.count, [self class]); 49 | return nil; 50 | } 51 | } 52 | - (id)jz_objectAtIndexedSubscript:(NSUInteger)index{ 53 | if (index < self.count) { 54 | 55 | return [self jz_objectAtIndexedSubscript:index]; 56 | }else{ 57 | NSLog(@" 你的NSMutableArray数组已经越界 帮你处理好了%ld %ld %@", index, self.count, [self class]); 58 | return nil; 59 | } 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /添加分类/NSObject+SwizzleMethod.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+SwizzleMethod.h 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/29. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (SwizzleMethod) 12 | 13 | /** 14 | * 对系统方法进行替换(交换实例方法) 15 | * 16 | * @param systemSelector 被替换的方法 17 | * @param swizzledSelector 实际使用的方法 18 | * @param error 替换过程中出现的错误消息 19 | * 20 | * @return 是否替换成功 21 | */ 22 | + (BOOL)SystemSelector:(SEL)systemSelector swizzledSelector:(SEL)swizzledSelector error:(NSError *)error; 23 | @end 24 | -------------------------------------------------------------------------------- /添加分类/NSObject+SwizzleMethod.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+SwizzleMethod.m 3 | // 数组越界 4 | // 5 | // Created by mic on 2017/12/29. 6 | // Copyright © 2017年 JZ. All rights reserved. 7 | // 8 | 9 | #import "NSObject+SwizzleMethod.h" 10 | #import 11 | 12 | @implementation NSObject (SwizzleMethod) 13 | 14 | /** 15 | * 对系统方法进行替换 16 | * 17 | * @param systemSelector 被替换的方法 18 | * @param swizzledSelector 实际使用的方法 19 | * @param error 替换过程中出现的错误消息 20 | * 21 | * @return 是否替换成功 22 | */ 23 | + (BOOL)SystemSelector:(SEL)systemSelector swizzledSelector:(SEL)swizzledSelector error:(NSError *)error{ 24 | 25 | Method systemMethod = class_getInstanceMethod(self, systemSelector); 26 | if (!systemMethod) { 27 | return [[self class] unrecognizedSelector:systemSelector error:error]; 28 | } 29 | 30 | Method swizzledMethod = class_getInstanceMethod(self, swizzledSelector); 31 | if (!swizzledMethod) { 32 | 33 | return [[self class] unrecognizedSelector:swizzledSelector error:error]; 34 | } 35 | 36 | if (class_addMethod([self class], systemSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))) { 37 | 38 | class_replaceMethod([self class], swizzledSelector, method_getImplementation(systemMethod), method_getTypeEncoding(systemMethod)); 39 | }else{ 40 | method_exchangeImplementations(systemMethod, swizzledMethod); 41 | } 42 | 43 | return YES; 44 | } 45 | 46 | + (BOOL)unrecognizedSelector:(SEL)selector error:(NSError *)error{ 47 | 48 | NSString *errorString = [NSString stringWithFormat:@"%@类没有找到%@", NSStringFromClass([self class]), NSStringFromSelector(selector)]; 49 | 50 | error = [NSError errorWithDomain:@"NSCocoaErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey:errorString}]; 51 | 52 | return NO; 53 | } 54 | 55 | @end 56 | --------------------------------------------------------------------------------