码迷,mamicode.com
首页 > 其他好文 > 详细

OC基础8

时间:2016-04-15 18:04:29      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

OC基础8

 

 【构造方法】
#  Person *p = [Person new];
#  new其实是+alloc与-init的结合:
#    (1)+alloc类方法进行分配空间
#    (2)-init对象方法进行初始化
#  Person *p1 = [Person alloc];
#  Person *p2 = [p1 init];




#  重写init方法
#  Person *p4 = [[Person alloc] init];

#- (id) init
#{
#    self = [super init];
#    if (self != 0)
#    {
#        _no = 1;
#    }
#    return self
#}


#
#- (id) init
#{
#    if (self = [super init]) #经典的写法
#    {
#        _no = 1;
#    }
#    return self
#}
#
#



#    自定义init方法
#   - (id)initWithAge:(int)age;




#    Xcode功能使用技巧
#   修改Xcode模板更改

OC基础8

标签:

原文地址:http://www.cnblogs.com/Wolfanature/p/5396083.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!