iOS常见crash整理

1.网络类

表现
1
*** Assertion failure in -[AFJSONRequestSerializer requestWithMethod:URLString:parameters:error:]
解决方案: url中包含中文时候需要转码
1
2
3
NSString *encoded = [link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
或者
stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]

2.UI类

表现
1
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_Run
解决方案: 退出页面时需要移除监听observe
1
[_footerView.scrollView removeObserver:self forKeyPath:@"contentSize"];