前言
在开发的时候经常会做一些代码安全防护,以防止开发中不确定的变量为空而导致App崩溃,或者做类的函数传参容错处理。
相关知识点
1.load 方法全程跟踪
2 .runtime
针对过往开发中遇到的崩溃和坑,个人做了以下类的处理
- NSArray
objectAtIndex: - NSDictionary
setObject:forKey:
setObject:forKeyedSubscript:
initWithObjects:forKeys:count:
objectForKey:
length - NSJSONSerialization
dataWithJSONObject:options:error:
JSONObjectWithData:options:error: - NSMutableAttributedString
replaceCharactersInRange:withString: - NSMutableString
replaceCharactersInRange:withString:
objectForKeyedSubscript: - NSNull
length - NSString
stringByAppendingString: - NSUserDefaults
setObject:forKey: - UIButton
setTitle:forState: - UILabel
setText: - UITextField
setText: - WKWebView
处理WKContentView的crash
具体代码实现 传送门在此