zoukankan      html  css  js  c++  java
  • Cannot assign to 'self' outside of a method in the init family

    重写父类的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];
    }
    解决方法:

    - (id) initWithMy { self = [super init]; }
  • 相关阅读:
    MongoDB 与 MySQL 性能比较
    PySpider简易教程
    使用redis有什么缺点
    禅道
    Shell02
    Shell01
    性能测试06
    性能测试05
    性能测试04
    性能测试03
  • 原文地址:https://www.cnblogs.com/hw140430/p/3970441.html
Copyright © 2011-2022 走看看