有时候我们重写父类的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];

}


关于error:Cannot assign to 'self' outside of a method in the init family的更多相关文章

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

    有时候我们重写父类的init方法时不注意将init后面的第一个字母写成了小写,在这个方法里面又调用父类的初始化方法(self = [super init];)时会报错,错误信息如下:error:Can ...

  2. vue运行报错error:Cannot assign to read only property 'exports' of object '#<Object>'

    用weex做项目的时候,npm start 之后一直报错error:Cannot assign to read only property 'exports' of object '#<Obje ...

  3. sdk uncaught third Error Cannot assign to read only property 'constructor' of object '#<V>' (小程序)

    sdk uncaught third Error Cannot assign to read only property 'constructor' of object '#<V>' 在a ...

  4. Cannot assign to 'self' outside of a method in the init family

    今天在重写父类的init方法时报错如下: error:Cannot assign to 'self' outside of a method in the init family 这种问题以前从来没有 ...

  5. 关于Cannot assign to 'self' outside of a method in the init family解决方法

    有时候我们重写父类的init方法时不注意将init后面的第一个字母写成了小写,在这个方法里面又调用父类的初始化方法(self = [super init];)时会报错,错误信息如下:error:Can ...

  6. Xcode工程编译错误:“Cannot assign to 'self' outside of a method in the init family”

    #import <Foundation/Foundation.h> @interface EOCRectangle : NSObject<NSCoding> @property ...

  7. TypeError: Error when calling the metaclass bases Cannot create a consistent method resolution

    Python Error when calling the metaclass bases Cannot create a consistent method resolution order (MR ...

  8. Error creating bean with name &#39;menuController&#39;: Injection of autowired dependency……

    出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed. ...

  9. Error creating bean with name &#39;memcachedClient&#39;...java.lang.OutOfMemoryError

    1,Tomcat启动报错例如以下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating ...

随机推荐

  1. linux查找文件命令

    (2)find /etc -name httpd.conf #在/etc目录下文件httpd.conf

  2. window maven安装(六)

    Maven 实战系列之在Windows上安装Maven Maven是一个优秀的构建工具(类似于 Ant, 但比 Ant 更加方便使用),能帮助我们自动化构建过程,从清理.编译.测试到生成报告,再到打包 ...

  3. springboot中的controller注解没有生效

    springboot中的controller注解没有生效  , 启动的Application类没有在controller的父目录或同级目录

  4. 如何从sql server导出到csv文件

    如何从sql server导出到csv文件,具体代码如下: private static void WriteHeader(SqlDataReader reader, TextWriter outpu ...

  5. 线段树懒标记好题 HDU4578

    (1)"1 x y c",代表 把区间 [x,y] 上的值全部加c (2)"2 x y c",代表 把区间 [x,y] 上的值全部乘以c (3)"3 ...

  6. Codeforces 629 A. Far Relative’s Birthday Cake

      A. Far Relative’s Birthday Cake   time limit per test 1 second memory limit per test 256 megabytes ...

  7. python安装numpy和matplotlib

    1.从该链接下载对应的whl文件 2.按照下面的方式从whl文件安装即可 windows7 python2.7 1.用管理员方式打开cmd 2.首先通过pip命令安装wheel 如果提示’pip’不是 ...

  8. Database | SQL

    Basic of MySQL 创建数据库: mysql> create database xxj; Query OK, row affected (0.00 sec) 列举数据库: mysql& ...

  9. codeforces A. In Search of an Easy Problem

    A. In Search of an Easy Problem time limit per test 1 second memory limit per test 256 megabytes inp ...

  10. 中途相遇法 解决 超大背包问题 pack

    Description [题目描述] 蛤布斯有n个物品和一个大小为m的背包,每个物品有大小和价值,它希望你帮它求出背包里最多能放下多少价值的物品. [输入数据] 第一行两个整数n,m.接下来n行每行两 ...