您的位置:首页 > 移动开发 > IOS开发

iOS 常见错误

2015-12-10 17:44 393 查看
真心感觉iOS定位错误很难定位,这里记录一下常见错误对应的解决办法。当然同样的错误可能导致的错误原因有很多,下面给出的解决办法可能不完全能解决问题

1. this class is not key value coding-compliant for the key xxx.

问题背景: 我使用XIB自定UITableViewCell时,在给控件连线时(IBOutlet)完之后允许项目报错。
解决办法: 鼠标选中File's Owner , 然后点击最右面连接面板的 show the Connections inspector,找到 Referencing Outlets ,如果每项后面有感叹号标记,那么将带有感叹号的全部删掉。 然后重新允许试试看 , good luck!





另外 File's Owner 不要设置Custom Class, 而自定义的Cell需要设置 Custom Class ---> Class xxxTableViewCell

2. 代码块中引用self

__unsafe_unretained __typeof(self) this = self;

3.-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object' 解决方法:

NSMutableDictionary*d =[[[NSUserDefaults standardUserDefaults] objectForKey:@"xxxx"] mutableCopy];

不要使用这种方式,也不要使用(Xxx *)强转方式,使用下面这种方式获取 NSMutableDictionary


修改:NSMutableDictionary *user =[NSMutableDictionary dictionaryWithDictionary:[[NSUserDefaults standardUserDefaults] ForKey:@"xxxx"]];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: