图片调整,暗黑模式屏蔽,加入防闪退代码
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
//
|
||||
// NSMutableArray+AvoidCrash.m
|
||||
// AvoidCrash
|
||||
//
|
||||
// Created by mac on 16/9/21.
|
||||
// Copyright © 2016年 chenfanfang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSMutableArray+AvoidCrash.h"
|
||||
|
||||
#import "AvoidCrash.h"
|
||||
|
||||
@implementation NSMutableArray (AvoidCrash)
|
||||
|
||||
+ (void)avoidCrashExchangeMethod {
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
|
||||
Class arrayMClass = NSClassFromString(@"__NSArrayM");
|
||||
|
||||
|
||||
//objectAtIndex:
|
||||
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(objectAtIndex:) method2Sel:@selector(avoidCrashObjectAtIndex:)];
|
||||
|
||||
//setObject:atIndexedSubscript:
|
||||
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(setObject:atIndexedSubscript:) method2Sel:@selector(avoidCrashSetObject:atIndexedSubscript:)];
|
||||
|
||||
|
||||
//removeObjectAtIndex:
|
||||
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(removeObjectAtIndex:) method2Sel:@selector(avoidCrashRemoveObjectAtIndex:)];
|
||||
|
||||
//insertObject:atIndex:
|
||||
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(insertObject:atIndex:) method2Sel:@selector(avoidCrashInsertObject:atIndex:)];
|
||||
|
||||
//getObjects:range:
|
||||
[AvoidCrash exchangeInstanceMethod:arrayMClass method1Sel:@selector(getObjects:range:) method2Sel:@selector(avoidCrashGetObjects:range:)];
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// array set object at index
|
||||
//=================================================================
|
||||
#pragma mark - get object from array
|
||||
|
||||
|
||||
- (void)avoidCrashSetObject:(id)obj atIndexedSubscript:(NSUInteger)idx {
|
||||
|
||||
@try {
|
||||
[self avoidCrashSetObject:obj atIndexedSubscript:idx];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// removeObjectAtIndex:
|
||||
//=================================================================
|
||||
#pragma mark - removeObjectAtIndex:
|
||||
|
||||
- (void)avoidCrashRemoveObjectAtIndex:(NSUInteger)index {
|
||||
@try {
|
||||
[self avoidCrashRemoveObjectAtIndex:index];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// insertObject:atIndex:
|
||||
//=================================================================
|
||||
#pragma mark - set方法
|
||||
- (void)avoidCrashInsertObject:(id)anObject atIndex:(NSUInteger)index {
|
||||
@try {
|
||||
[self avoidCrashInsertObject:anObject atIndex:index];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:AvoidCrashDefaultIgnore];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// objectAtIndex:
|
||||
//=================================================================
|
||||
#pragma mark - objectAtIndex:
|
||||
|
||||
- (id)avoidCrashObjectAtIndex:(NSUInteger)index {
|
||||
id object = nil;
|
||||
|
||||
@try {
|
||||
object = [self avoidCrashObjectAtIndex:index];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSString *defaultToDo = AvoidCrashDefaultReturnNil;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
}
|
||||
@finally {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// getObjects:range:
|
||||
//=================================================================
|
||||
#pragma mark - getObjects:range:
|
||||
|
||||
- (void)avoidCrashGetObjects:(__unsafe_unretained id _Nonnull *)objects range:(NSRange)range {
|
||||
|
||||
@try {
|
||||
[self avoidCrashGetObjects:objects range:range];
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
NSString *defaultToDo = AvoidCrashDefaultIgnore;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
|
||||
} @finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user