NSObject+AvoidCrash.h 998 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // NSObject+AvoidCrash.h
  3. // https://github.com/chenfanfang/AvoidCrash
  4. //
  5. // Created by mac on 16/10/11.
  6. // Copyright © 2016年 chenfanfang. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @interface NSObject (AvoidCrash)
  10. /**
  11. * ifDealWithNoneSel : 是否开启"unrecognized selector sent to instance"异常的捕获
  12. */
  13. + (void)avoidCrashExchangeMethodIfDealWithNoneSel:(BOOL)ifDealWithNoneSel;
  14. + (void)setupNoneSelClassStringsArr:(NSArray<NSString *> *)classStrings;
  15. + (void)setupNoneSelClassStringPrefixsArr:(NSArray<NSString *> *)classStringPrefixs;
  16. @end
  17. /**
  18. * Can avoid crash method
  19. *
  20. * 1.- (void)setValue:(id)value forKey:(NSString *)key
  21. * 2.- (void)setValue:(id)value forKeyPath:(NSString *)keyPath
  22. * 3.- (void)setValue:(id)value forUndefinedKey:(NSString *)key //这个方法一般用来重写,不会主动调用
  23. * 4.- (void)setValuesForKeysWithDictionary:(NSDictionary<NSString *,id> *)keyedValues
  24. * 5. unrecognized selector sent to instance
  25. */