有时候我们重写父类的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:C ...

  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. 处理异常json串的jar包JsonSerde

    参考下面文章: https://blog.csdn.net/SunnyYoona/article/details/70170173

  2. 【html5】html5 本地存储

    最近一直在学习 html5,为了后期的移动项目进行知识储备.html5 相对于 html4 新增加了一些有趣的标签.属性和方法,今天主要介绍下 html5 的本地存储. 在客户端存储数据 html5 ...

  3. Web API(六):使用Autofac实现依赖注入

    在这一篇文章将会讲解如何在Web API2中使用Autofac实现依赖注入. 一.创建实体类库 1.创建单独实体类 创建DI.Entity类库,用来存放所有的实体类,新建用户实体类,其结构如下: us ...

  4. maven-parent的pom.xml配置

    //-------------------------------------------system-parent------------------------------------------ ...

  5. USB学习笔记连载(八):FX2替换到FX2LP需要注意事项

    对于使用FX2的用户,可以升级到FX2LP,上述的应用笔记<AN4078-C>中就讲解了在升级中的注意事项.   必要的修改:   1.晶振的匹配电容需要更改,FX2LP是12pF,不过笔 ...

  6. Eclipse中配置resin 4.x

    开发web项目时,你还困扰在,反复启动web容器的痛苦中么?也许会有人说,用调试模式.但是如果涉及到配置文件或者service类,还是不得不重启web容器吧,而且偶尔会出现抽风情况,没生效的情况(这时 ...

  7. SAP MM/FI 自动过账实现 OBYC 接口执行

    一. 自动过账原理 在MM模块的许多操作都能实现在FI模块自动过账,如PO收货.发票验证(LIV).工单发料.向生产车间发料等等.不用说,一定需要在IMG中进行配置才可以实现自动处理.但SAP实现的这 ...

  8. SpringMVC系列(一)SpringMVC概述和搭建SpringMVC的第一个helloWord入门程序

    一.SpringMVC 概述 • Spring为展现层提供的基于MVC设计理念的优秀的Web框架,是目前最主流的MVC框架之一 • Spring3.0 后全面超越 Struts2,成为最优秀的 MVC ...

  9. C# 通过调用Win32 API函数清除浏览器缓存和cookie

    public enum ShowCommands : int { SW_HIDE = , SW_SHOWNOrmAL = , SW_NOrmAL = , SW_SHOWMINIMIZED = , SW ...

  10. utf8_unicode_ci与utf8_general_ci的区别

    From: http://www.chinaz.com/program/2010/0225/107151.shtml 当前,utf8_unicode_ci校对规则仅部分支持Unicode校对规则算法. ...