Cannot assign to 'self' outside of a method in the init family
来源:互联网 发布:安卓扫雷源码 编辑:程序博客网 时间:2024/06/05 02:06
有时候我们重写父类的init方法时不注意将init后面的第一个字母写成了小写,在这个方法里面又调用父类的初始化方法(self = [super init];)时会报错,错误信息如下:error:Cannot assign to 'self' outside of a method in the init family
原因:只能在init方法中给self赋值,Xcode判断是否为init方法规则:方法返回id,并且名字以init+大写字母开头+其他 为准则。例如:- (id) initWithXXX;
出错代码:- (id) Myinit{
self = [super init];
……
}
解决方法:- (id) initWithMy
{
self = [super init];
}
0 0
- cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- [IOS] 错误:Cannot assign to 'self' outside of a method in the init family
- [ios]关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to \'self\' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- Cannot assign to 'self' outside of a method in the init family
- 关于error:Cannot assign to 'self' outside of a method in the init family
- 子类中初始化错误Cannot assign to ’self’ outside of a method in the init family
- apache几种工作模式对比
- Leetcode: Largest Number
- HDU 3980 Paint Chain(博弈 SG)
- 【机器学习】机器学习(一)——基于概率论的分类
- iOS开发-ARC下weak strong使用
- Cannot assign to 'self' outside of a method in the init family
- LeetCode 17.Letter Combinations of a Phone Number
- 上楼梯问题
- Projections常用的聚合查询方法介绍
- burpsuit安装及使用教程
- 构造函数和析构函数是否可以被重载
- Codeforces 490A Team Olympiad(水)
- android之绑定服务调用服务的方法
- HDU 4355 - Party All the Time(三分)