图片调整,暗黑模式屏蔽,加入防闪退代码
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// NSObject+AvoidCrash.m
|
||||
// AvoidCrashDemo
|
||||
//
|
||||
// Created by mac on 16/10/11.
|
||||
// Copyright © 2016年 chenfanfang. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSObject+AvoidCrash.h"
|
||||
|
||||
#import "AvoidCrash.h"
|
||||
|
||||
@implementation NSObject (AvoidCrash)
|
||||
|
||||
+ (void)avoidCrashExchangeMethod {
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
//setValue:forKey:
|
||||
[AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forKey:) method2Sel:@selector(avoidCrashSetValue:forKey:)];
|
||||
|
||||
//setValue:forKeyPath:
|
||||
[AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forKeyPath:) method2Sel:@selector(avoidCrashSetValue:forKeyPath:)];
|
||||
|
||||
//setValue:forUndefinedKey:
|
||||
[AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValue:forUndefinedKey:) method2Sel:@selector(avoidCrashSetValue:forUndefinedKey:)];
|
||||
|
||||
//setValuesForKeysWithDictionary:
|
||||
[AvoidCrash exchangeInstanceMethod:[self class] method1Sel:@selector(setValuesForKeysWithDictionary:) method2Sel:@selector(avoidCrashSetValuesForKeysWithDictionary:)];
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=================================================================
|
||||
// setValue:forKey:
|
||||
//=================================================================
|
||||
#pragma mark - setValue:forKey:
|
||||
|
||||
- (void)avoidCrashSetValue:(id)value forKey:(NSString *)key {
|
||||
@try {
|
||||
[self avoidCrashSetValue:value forKey:key];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSString *defaultToDo = AvoidCrashDefaultIgnore;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// setValue:forKeyPath:
|
||||
//=================================================================
|
||||
#pragma mark - setValue:forKeyPath:
|
||||
|
||||
- (void)avoidCrashSetValue:(id)value forKeyPath:(NSString *)keyPath {
|
||||
@try {
|
||||
[self avoidCrashSetValue:value forKeyPath:keyPath];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSString *defaultToDo = AvoidCrashDefaultIgnore;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=================================================================
|
||||
// setValue:forUndefinedKey:
|
||||
//=================================================================
|
||||
#pragma mark - setValue:forUndefinedKey:
|
||||
|
||||
- (void)avoidCrashSetValue:(id)value forUndefinedKey:(NSString *)key {
|
||||
@try {
|
||||
[self avoidCrashSetValue:value forUndefinedKey:key];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSString *defaultToDo = AvoidCrashDefaultIgnore;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================
|
||||
// setValuesForKeysWithDictionary:
|
||||
//=================================================================
|
||||
#pragma mark - setValuesForKeysWithDictionary:
|
||||
|
||||
- (void)avoidCrashSetValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues {
|
||||
@try {
|
||||
[self avoidCrashSetValuesForKeysWithDictionary:keyedValues];
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
NSString *defaultToDo = AvoidCrashDefaultIgnore;
|
||||
[AvoidCrash noteErrorWithException:exception defaultToDo:defaultToDo];
|
||||
}
|
||||
@finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user