地址 | 簡(jiǎn)介 |
---|---|
iOS被開發(fā)者遺忘在角落的NSException-其實(shí)它很強(qiáng)大 | NSException |
利用category + runtime + 異常的捕獲 來(lái)寫一個(gè)防止崩潰的框架 | AvoidCrash異常處理框架 |
iOS正則表達(dá)式的使用(NSRegularExpression) | AvoidCrash異常處理框架 |
正則表達(dá)式30分鐘入門教程 | 正則表達(dá)式看了n遍焦蘑,還得從頭看 |
https://github.com/Broszhu/zhuanbang-javascript-notes
[-+][.+]
-[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects 匹配 -[__NSPlaceholderArray initWithObjects:count:]盯拱;如果后面有[1],匹配一整行;
// C字符串轉(zhuǎn)為OC字符串
#define CStringToOcString(cstr) [NSString stringWithCString:cstr encoding:GBK_ENCODE]
NSDictionary+AvoidCrash.h
/**
* Can avoid crash method
*
* 1. NSDictionary的快速創(chuàng)建方式 NSDictionary *dict = @{@"frameWork" : @"AvoidCrash"}; //這種創(chuàng)建方式其實(shí)調(diào)用的是2中的方法
* 2. +(instancetype)dictionaryWithObjects:(const id _Nonnull __unsafe_unretained *)objects forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys count:(NSUInteger)cnt
*
*/
錯(cuò)誤處理狡逢,移除空的鍵值對(duì)key-value宁舰,再創(chuàng)建字典dic
/**
* 類方法的交換
*
* @param anClass 哪個(gè)類
* @param method1Sel 方法1
* @param method2Sel 方法2
*/
+ (void)exchangeClassMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel {
Method method1 = class_getClassMethod(anClass, method1Sel);
Method method2 = class_getClassMethod(anClass, method2Sel);
method_exchangeImplementations(method1, method2);
}
/**
* 對(duì)象方法的交換
*
* @param anClass 哪個(gè)類
* @param method1Sel 方法1
* @param method2Sel 方法2
*/
+ (void)exchangeInstanceMethod:(Class)anClass method1Sel:(SEL)method1Sel method2Sel:(SEL)method2Sel {
Method method1 = class_getInstanceMethod(anClass, method1Sel);
Method method2 = class_getInstanceMethod(anClass, method2Sel);
method_exchangeImplementations(method1, method2);
}