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

OC中的self

时间:2014-10-23 14:38:24      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   sp   on   log   代码   bs   new   

代码:

#import <Foundation/Foundation.h>

@interface MyClass : NSObject

- (void) funcA;
- (void) funcAA;
+ (void) funcA;
+ (void) funcAA;

@end

@implementation MyClass

- (void) funcA
{
    NSLog(@"-funcA");
    [self funcAA];
}

- (void) funcAA
{
    NSLog(@"-funcAA");
}

+ (void) funcA
{
    NSLog(@"+funcA");
    [self funcAA];
}

+ (void) funcAA
{
    NSLog(@"+funcAA");
}

@end

int main(void)
{
    
    [MyClass funcA];
    
    MyClass* pmc = [MyClass new];
    [pmc funcA];
    
    return 0;
}

输出:

+funcA
+funcAA
-funcA
-funcAA


OC中的self

标签:style   io   ar   sp   on   log   代码   bs   new   

原文地址:http://my.oschina.net/Xwoder/blog/336535

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