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

}

转载自http://www.aichengxu.com/view/34741

关于Cannot assign to 'self' outside of a method in the init family解决方法的更多相关文章

  1. 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 这种问题以前从来没有 ...

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

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

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

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

  4. 关于vue-cli3打包时遇到Cannot assign to read only property 'exports' of object '#<Object>'问题的解决方法。

    vue-cli3打包时遇到Cannot assign to read only property 'exports' of object '#<Object>'问题的解决方法. 大致是说, ...

  5. 关于error:Cannot assign to &#39;self&#39; outside of a method in the init family

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

  6. php连接memcahed出现Cannot assign requested address (99)的解决方法

    今天在将服务器合并后,发现php偶尔会报出 Server *.*.*.* (tcp *****) failed with: Cannot assign requested address (99) 的 ...

  7. Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法

    发现问题 运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncau ...

  8. tomcat java.net.BindException: Cannot assign requested address 解决方法

    今天线上TOMCAT启动时遇到了下比较麻烦的问题,错误如下: 21-Apr-2016 15:14:19.077 SEVERE [main] org.apache.catalina.core.Stand ...

  9. 对于高并发短连接造成Cannot assign requested address解决方法

    https://www.cnblogs.com/dadonggg/p/8778318.html 感谢这篇文章给予的启发 在tcp四次挥手断开连接时,主动释放连接的一方最后会进入TIME_WAIT状态, ...

随机推荐

  1. 海量字符串查找——bloom filter,c

    对于海量字符串的查找,一般有两种方法,一种是建树,还有一种就是bf算法,即布隆过滤器,这个从原来上讲比较简单,也易于实现,主要就是根据哈希算法来实现. int len(char *ch) { int ...

  2. 什么是HTML、XML和XHTML

    (1)XMLXML是The Extensible Markup Language(可扩展标识语言)的简写.目前推荐遵循的是W3C于2000年10月6日发布的XML1.0,参考(www.w3.org/T ...

  3. C++@子类类型转换为父类类型

    static_cast(*this) to a base class create a temporary copy. class Window { // base class public: vir ...

  4. eclipse常用插件在线安装地址或下载地址

    本文转载自:http://my.oschina.net/bloghu/blog/198922 一,反编译插件: A.Jadclipse 1.打开eclipse增加站点:http://jadclipse ...

  5. unbuntu下安装flash插件

    adobe flash player的官方下载页面为:https://get.adobe.com/cn/flashplayer/ 不过近期通过APT方式以及ubuntu的软件中心都安装不了flashp ...

  6. 胶囊碰撞体(CapsuleCollider)

    胶囊碰撞体 (Capsule Collider) 胶囊碰撞体 (Capsule Collider) 由两个半球体与一个圆柱体相连接而构成.它与胶囊 (Capsule) 基元形状相同.   一堆胶囊碰撞 ...

  7. FSM, VISIBILITY MAP AND VACUUM

    Update: Heikki’s slides are here! Heikki Linnakangas gave a presentation this past Sunday at FOSDEM  ...

  8. ibm硬件知识点

    ibm http://www-03.ibm.com/systems/storage/disk/storwize_v3700/index.html Current software level: Ver ...

  9. shell之脚本片断

    16. 以下是平台信息 CentOS Linux release 7.1.1503 (Core) Linux mysql-dev1 3.10.0-229.el7.x86_64 #1 SMP Fri M ...

  10. 搭建EF6.0+MVC4搭建框架——之路由配置

    为了适应项目需求,需要将前后台的控制器和视图等文件分开,便于修改和维护: 方案一:在原有的Controller下新增Admins文件夹用于放置后台控制器文件: 控制器文件目录如下图: 视图文件目录: