仅仅作为一个crash记录笔记。
通过crash log可以查看报错:
作为个人开发警告,严格检查数据,查看系统api
1. 字符串传NSNull
-[NSNull isEqualToString:]: unrecognized selector sent to instance 0x1c45997e0
2.数组传NSNull
-[NSNull length]: unrecognized selector sent to instance 0x1b6dd0878
3.照相机闪光灯模式,iOS10前后有区别
-[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] flashMode must be set to a value present in the supportedFlashModes array
/*!
@property supportedFlashModes
@abstract
An array of AVCaptureFlashMode constants for the current capture session configuration.
@discussion
This property supersedes AVCaptureDevice's isFlashModeSupported: It returns an array of AVCaptureFlashMode constants. To test whether a particular flash mode is supported, use NSArray's containsObject API: [photoOutput.supportedFlashModes containsObject:@(AVCaptureFlashModeAuto)]. This property is key-value observable.
*/
@property(nonatomic, readonly) NSArray<NSNumber *> *supportedFlashModes;
4.自定义相机api在多个iOS版本中有区别,要不适配最低版本,要不要非常小心区分。
-[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] Settings may not be re-used'
5.AFNetWorking发送post请求,Code=-1016错误
JSON text did not start with array or object and option to allow fragments not set
Code=-1016 “Request failed: unacceptable content-type: text/plain” UserInfo=0x7a2da380
下面问题是因为AF不支持text/json的情况,需要加上
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
或
manager.responseSerializer.acceptableContentTypes=[NSSet setWithObjects:@"application/json", @"text/json",@"text/html",@"text/javascript", nil];
所以还是没有解决我的上面报错问题,于是和后台进行交流,发现后台返回的数据中没有提供content-type 的字段,所以造成了无法解析的问题,果断让后台加上,立即OK
https://blog.csdn.net/dawy_wei/article/details/60582156
6. 两个view,tag相同成为父子视图导致RunLoop Crash
[cell.contentView addSubview:self.subTableView];
tableview嵌套崩溃 两个tableview tag相同
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
7. 初始化一个全局变量或static变量时,只能用常量赋值,不能用变量赋值!
Initializer element is not a compile-time constant
8.对象深拷贝
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[YYXXObject mutableCopyWithZone:]: unrecognized selector sent to instance 0x2815c0c80'
要想自定义对象可以复制,那么该类就必须
方法一:
一,遵守NSCopying 或 NSMutableCopying协议。
二,实现协议中copyWithZone或者mutableCopyWithZone方法。
方法二:
创建新对象,手动给每个参数赋值。
9.深拷贝对象执行mutablecopy
[YY***Object mutableCopyWithZone:]: unrecognized selector sent to instance 0x155af900
仔细研究mutablecopy
10.Autolayout出错
*** Assertion failure in -[MASViewConstraint install], /***/Pods/Masonry/Masonry/MASViewConstraint.m:343
2019-07-30 11:56:42.735419+0800 YiYunSTP[5789:1180495] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'couldn't find a common superview for <YYCardView: 0x129300830; frame = (0 0; 0 0); layer = <CALayer: 0x283bdcdc0>> and <UIView: 0x127e16fc0; frame = (0 64; 414 672); autoresize = W+H; layer = <CALayer: 0x283b6bac0>>'
原因:给没有添加的视图添加布局,所以每次改布局注意清空没有用到的控件。
11.数组插入nil
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]'
数组中放入nil这个元素导致的崩溃;