diff --git a/SafeKit/Foundation/NSArray+SafeKit.m b/SafeKit/Foundation/NSArray+SafeKit.m index de8b3ae..90b61ad 100644 --- a/SafeKit/Foundation/NSArray+SafeKit.m +++ b/SafeKit/Foundation/NSArray+SafeKit.m @@ -30,6 +30,13 @@ - (id)safe_objectAtIndex:(NSUInteger)index { return [self safe_objectAtIndex:index]; } +- (id)safe_objectAtIndexedSubscript:(NSUInteger)index { + if (index >= [self count]) { + return nil; + } + return [self safe_objectAtIndexedSubscript:index]; +} + - (NSArray *)safe_arrayByAddingObject:(id)anObject { if (!anObject) { return self; @@ -42,6 +49,7 @@ + (void)load { dispatch_once(&onceToken, ^{ [self safe_swizzleMethod:@selector(initWithObjects_safe:count:) tarClass:@"__NSPlaceholderArray" tarSel:@selector(initWithObjects:count:)]; [self safe_swizzleMethod:@selector(safe_objectAtIndex:) tarClass:@"__NSArrayI" tarSel:@selector(objectAtIndex:)]; + [self safe_swizzleMethod:@selector(safe_objectAtIndexedSubscript:) tarClass:@"__NSArrayI" tarSel:@selector(objectAtIndexedSubscript:)]; [self safe_swizzleMethod:@selector(safe_arrayByAddingObject:) tarClass:@"__NSArrayI" tarSel:@selector(arrayByAddingObject:)]; }); } diff --git a/SafeKit/Foundation/NSMutableDictionary+SafeKit.m b/SafeKit/Foundation/NSMutableDictionary+SafeKit.m index 416490b..43c2a0c 100644 --- a/SafeKit/Foundation/NSMutableDictionary+SafeKit.m +++ b/SafeKit/Foundation/NSMutableDictionary+SafeKit.m @@ -18,6 +18,17 @@ - (void)safe_removeObjectForKey:(id)aKey { [self safe_removeObjectForKey:aKey]; } +- (void)safe_setObject:(id)anObject forKeyedSubscript:(id )aKey { + if (!anObject) { + return; + } + if (!aKey) { + return; + } + [self safe_setObject:anObject forKeyedSubscript:aKey]; +} + + - (void)safe_setObject:(id)anObject forKey:(id )aKey { if (!anObject) { return; @@ -33,6 +44,8 @@ + (void) load { dispatch_once(&onceToken, ^{ [self safe_swizzleMethod:@selector(safe_removeObjectForKey:) tarClass:@"__NSDictionaryM" tarSel:@selector(removeObjectForKey:)]; [self safe_swizzleMethod:@selector(safe_setObject:forKey:) tarClass:@"__NSDictionaryM" tarSel:@selector(setObject:forKey:)]; + [self safe_swizzleMethod:@selector(safe_setObject:forKeyedSubscript:) tarClass:@"__NSDictionaryM" tarSel:@selector(setObject:forKeyedSubscript:)]; + }); } diff --git a/SafeKit/MRC/NSMutableArray+SafeKitMRC.m b/SafeKit/MRC/NSMutableArray+SafeKitMRC.m index 9d541c5..833aed7 100644 --- a/SafeKit/MRC/NSMutableArray+SafeKitMRC.m +++ b/SafeKit/MRC/NSMutableArray+SafeKitMRC.m @@ -19,10 +19,19 @@ - (id)safe_objectAtIndex:(NSUInteger)index { return [self safe_objectAtIndex:index]; } + +- (id)safe_objectAtIndexedSubscript:(NSUInteger)index { + if (index >= [self count]) { + return nil; + } + return [self safe_objectAtIndexedSubscript:index]; +} + + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [self safe_swizzleMethod:@selector(safe_objectAtIndex:) tarClass:@"__NSArrayM" tarSel:@selector(objectAtIndex:)]; + [self safe_swizzleMethod:@selector(safe_objectAtIndexedSubscript:) tarClass:@"__NSArrayM" tarSel:@selector(objectAtIndexedSubscript:)]; }); } diff --git a/SafeKitExample/SafeKitExample.xcodeproj/project.pbxproj b/SafeKitExample/SafeKitExample.xcodeproj/project.pbxproj index 42e2008..43085ec 100644 --- a/SafeKitExample/SafeKitExample.xcodeproj/project.pbxproj +++ b/SafeKitExample/SafeKitExample.xcodeproj/project.pbxproj @@ -695,7 +695,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = SafeKitExample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.zhangyu.SafeKitExample; @@ -708,7 +708,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = SafeKitExample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 6.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = "-ObjC"; PRODUCT_BUNDLE_IDENTIFIER = com.zhangyu.SafeKitExample; diff --git a/SafeKitExample/SafeKitExample.xcodeproj/project.xcworkspace/xcuserdata/wangrongchao.xcuserdatad/UserInterfaceState.xcuserstate b/SafeKitExample/SafeKitExample.xcodeproj/project.xcworkspace/xcuserdata/wangrongchao.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..af389b1 Binary files /dev/null and b/SafeKitExample/SafeKitExample.xcodeproj/project.xcworkspace/xcuserdata/wangrongchao.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SafeKitExample/SafeKitExample.xcodeproj/xcuserdata/wangrongchao.xcuserdatad/xcschemes/xcschememanagement.plist b/SafeKitExample/SafeKitExample.xcodeproj/xcuserdata/wangrongchao.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..38eac68 --- /dev/null +++ b/SafeKitExample/SafeKitExample.xcodeproj/xcuserdata/wangrongchao.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + SafeKitExample.xcscheme + + orderHint + 1 + + SafeKitLib.xcscheme + + orderHint + 0 + + + + diff --git a/SafeKitExample/SafeKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/SafeKitExample/SafeKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..d8db8d6 100644 --- a/SafeKitExample/SafeKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/SafeKitExample/SafeKitExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", @@ -30,6 +40,16 @@ "size" : "60x60", "scale" : "3x" }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, { "idiom" : "ipad", "size" : "29x29", @@ -59,6 +79,16 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : {