首页 > 其他 > 详细

关于error:Cannot assign to 'self' outside of a method in the init family

时间:2015-10-07 14:45:38      阅读:248      评论:0      收藏:0      [点我收藏+]

在很多时候我们都要重写初始化方法。而“error:Cannot assign to ‘self‘ outside of a method in the init family”这个错误是基于初始化方法

名的编写错误导致的。

原因在于:

Xcode判断是否为init方法规则:方法返回id,并且名字以init+大写字母开头+其他  为准则。例如:- (id) initWithXXX;

出错代码:- (instancetype) Myinit{

 self = [super init];

 ……

}

解决方法:- (instancetype) initWithMy

{

 self = [super init];

}

关于error:Cannot assign to 'self' outside of a method in the init family

原文:http://www.cnblogs.com/djrLog/p/4858636.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!