zhangchioulin
V2EX  ›  问与答

我想问一个 object-c 中的几个问题。请知道的朋友帮我看下,谢谢

  •  
  •   zhangchioulin · Apr 27, 2015 · 2332 views
    This topic created in 4060 days ago, the information mentioned may be changed or developed.
    1/我新建了一个Cocoa Touch Class 的类也写了代码,但是没有在ViewController中写关于那个类的代码,程序会不会自动帮我运行一遍那个类中的方法?

    2/感觉这门语言中的[]符号有点难懂,能说一下该在哪里用吗?
    8 replies    2015-04-29 19:52:03 +08:00
    yanchao7511461
        1
    yanchao7511461  
       Apr 27, 2015
    刚看了一点语法。。。 []不是消息传递么? 可以理解成对象调用函数..... 刚开始看两天....
    zhangchioulin
        2
    zhangchioulin  
    OP
       Apr 27, 2015 via iPhone
    @yanchao7511461 这个倒知道,就是有时候它调用的莫名其妙 比如说if
    zhangchioulin
        3
    zhangchioulin  
    OP
       Apr 27, 2015 via iPhone
    我在class中设置了断点代码完全没有用到。该怎么用呢
    1q2w3e4r
        4
    1q2w3e4r  
       Apr 28, 2015
    init你的类、并调用你设置断点的方法。所有的语言不都是这样吗
    zhangchioulin
        5
    zhangchioulin  
    OP
       Apr 28, 2015
    @1q2w3e4r 是在哪里init呢?感觉好无力
    1q2w3e4r
        6
    1q2w3e4r  
       Apr 29, 2015
    比如:你定义一个A,并些了test方法。断点这个方法
    @interface A : NSObject

    @end

    @implementation A

    - (void)test
    {

    }
    @end

    在ViewController里
    - (void)viewDidLoad
    {
    [super viewDidLoad];
    A *a= [[A alloc] init];
    [a test];
    }
    1q2w3e4r
        7
    1q2w3e4r  
       Apr 29, 2015   ❤️ 1
    @zhangchioulin 你应该先了解下语言基础
    zhangchioulin
        8
    zhangchioulin  
    OP
       Apr 29, 2015
    @1q2w3e4r 谢谢,我打算五一的时候把Objc基础看会
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2909 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 15:04 · PVG 23:04 · LAX 08:04 · JFK 11:04
    ♥ Do have faith in what you're doing.