有时候我们重写父类的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. leetcode 128. Longest Consecutive Sequence ----- java

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  2. 用类求圆面积c++

    #include<iostream>.#include<math.h>using namespace std;class Circle{    public:        d ...

  3. java .net compartion

    1, http://www-01.ibm.com/software/smb/na/J2EE_vs_NET_History_and_Comparison.pdf http://stackoverflow ...

  4. BEA-WEBLOGIC ---http://www.beansoft.biz/weblogic/docs92/index.html

    WebLogic Home      英文对照      发行信息 站点地图 Installation Guide 新增功能 已知和已解决的问题 Upgrade Guide Installing Ma ...

  5. linux包之bash之内置命令ulimit

    概述 [root@localhost ~]# rpm -qa|grep bashbash-4.1.2-15.el6_4.x86_64 linux limits.conf 配置 limits.conf ...

  6. vs2010设置 "行号显示"

    Microsoft Visual Studio 2010 默认情况下是不显示代码的行号的.在编译出错时,可点击下面输出窗口中的错误提示进行定位. 但是这样操作起来你有没有感觉到不方便呢. 不显示行号时 ...

  7. 【转】关于PHP的header("P3P: CP=CURa……")

    对于IE来说(默认安全级别下),iframe.img.link等标签都是只发送session cookie(又叫 第一方cookie),拦截本地cookie发送(又叫第三方cookie).当这些标签跨 ...

  8. 简单实现JS Loading功能

    我们经常在浏览网页的时候会看到数据在加载时,出现的LOADING提示.其实这个功能原理是很简单的,就是一个DIV遮盖当前页面,然后Loading就在遮盖DIV层上展示出来,现在我们来动手实现一下. 1 ...

  9. mysql 远程访问授权

    给mysql改了密码了,程序就不让登录了: mysql 网外链接 Access denied for user 这不能忍啊!咋办?授权呗! 命令行: GRANT ALL PRIVILEGES ON * ...

  10. SQL SERVER 拆分列为多行

    --创建测试表 )) insert into #temp(names) values('张三,李四'), ('中国,美国,巴西'), ('深圳,上海,北京,广州,哈尔滨'), ('足球,篮球,乒乓球, ...