OC self注意事项


 1 #import <Foundation/Foundation.h>
 2 
 3 @interface Person : NSObject
 4 - (void)test;
 5 + (void)test;
 6 
 7 - (void)test1;
 8 + (void)test2;
 9 
10 
11 - (void)haha1;
12 
13 + (void)haha2;
14 
15 
16 @end
17 
18 @implementation Person
19 - (void)test
20 {
21     NSLog(@"调用了-test方法");
22     
23     // 会引发死循环
24     //[self test];
25 }
26 
27 + (void)test
28 {
29     NSLog(@"调用了+test方法");
30     
31     // 会引发死循环
32     //[self test];
33 }
34 
35 - (void)test1
36 {
37     [self test]; // -test
38 }
39 
40 + (void)test2
41 {
42     [self test]; // +test
43 }
44 
45 - (void)haha1
46 {
47     NSLog(@"haha1-----");
48 }
49 
50 
51 void haha3()
52 {
53     
54 }
55 
56 + (void)haha2
57 {
58     // haha3();
59     [self haha3];
60     // [self haha1];
61 }
62 @end
63 
64 int main()
65 {
66     [Person haha2];
67     //Person *p = [Person new];
68     
69     //[p test1];
70     return 0;
71 }

优质内容筛选与推荐>>
1、VerificationCodeService
2、Docker整体结构了解(2)
3、Bootstrap之网格类
4、java--知识运用
5、设计模式原则之接口隔离原则


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号