Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions AvoidCrash/NSArray+AvoidCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ + (void)avoidCrashExchangeMethod {


//objectAtIndex:

[AvoidCrash exchangeInstanceMethod:__NSArrayI method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSArrayIAvoidCrashObjectAtIndex:)];
if (@available(iOS 11.0, *)) {
[AvoidCrash exchangeInstanceMethod:__NSArrayI method1Sel:@selector(objectAtIndexedSubscript:) method2Sel:@selector(__NSArrayIAvoidCrashObjectAtIndex:)];
}else{

[AvoidCrash exchangeInstanceMethod:__NSArrayI method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSArrayIAvoidCrashObjectAtIndex:)];
}

[AvoidCrash exchangeInstanceMethod:__NSSingleObjectArrayI method1Sel:@selector(objectAtIndex:) method2Sel:@selector(__NSSingleObjectArrayIAvoidCrashObjectAtIndex:)];

Expand Down
6 changes: 5 additions & 1 deletion AvoidCrash/NSMutableArray+AvoidCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ + (void)avoidCrashExchangeMethod {


//objectAtIndex:
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(objectAtIndex:) method2Sel:@selector(avoidCrashObjectAtIndex:)];
if (@available(iOS 11.0, *)) {
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(objectAtIndexedSubscript:) method2Sel:@selector(avoidCrashObjectAtIndex:)];
}else{
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(objectAtIndex:) method2Sel:@selector(avoidCrashObjectAtIndex:)];
}

//setObject:atIndexedSubscript:
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(setObject:atIndexedSubscript:) method2Sel:@selector(avoidCrashSetObject:atIndexedSubscript:)];
Expand Down
9 changes: 8 additions & 1 deletion AvoidCrash/NSMutableDictionary+AvoidCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ + (void)avoidCrashExchangeMethod {
Class dictionaryM = NSClassFromString(@"__NSDictionaryM");

//setObject:forKey:
[AvoidCrash exchangeInstanceMethod:dictionaryM method1Sel:@selector(setObject:forKey:) method2Sel:@selector(avoidCrashSetObject:forKey:)];

if (@available(iOS 11.0, *)) {
[AvoidCrash exchangeInstanceMethod:dictionaryM method1Sel:@selector(forKeyedSubscript:forKey:) method2Sel:@selector(avoidCrashSetObject:forKey:)];
}else{
[AvoidCrash exchangeInstanceMethod:dictionaryM method1Sel:@selector(setObject:forKey:) method2Sel:@selector(avoidCrashSetObject:forKey:)];
}




//removeObjectForKey:
Expand Down