iOS学习(项目中遇到的错误1)

时间:2023-03-10 04:59:11
iOS学习(项目中遇到的错误1)

1.[AppModel copyWithZone:]: unrecognized selector sent to instance 0x7ffda9f4cf70

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppModel copyWithZone:]: unrecognized selector sent to instance 0x7ffda9f4cf70'

*** First throw call stack:

这样的错误的原因:属性定义的问题应该注意在定义属性时即在定义

property时几个出现故障的可能能

nonatomic:单线程,效率较高

atomic:多线程,效率长处低,可是是默认的

readWrite:可读可写,它也是默认的

readOnly:仅仅可读

assign:指的是int,float.等数值类型,他是默认的

copy:指的是字符串对象。

比如名字

retain:指的是对象。

比如时间对象

strong:强引用

weak:弱引用

我出错的原因就是在定义类对象时,误用了copy取代strong

2. 在使用tableView时会发现有时这种方法不运行,原因:_tableView的frame未设置。还有就是_dataArry未赋值是空的。

另一种就是在取的数据时採用的是异步的方式,可是木有刷新tableView数据

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath{

return
nil;

}

3.数据NSData未初始化带来的错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

4.假设取出的数据有为空时就会出现例如以下错误

 *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]'