Objective-C pointers?

前端 未结 7 1666
无人及你
无人及你 2020-12-29 10:49

I am new to coding and trying to get up to speed with Objective-C. Came across some code I did not understand. I was hoping someone could clarify it for me. In the case belo

7条回答
  •  孤城傲影
    2020-12-29 11:08

    From your simple example it is really hard to say what is going on. Typically [class add:] type methods return void, so they should raise a compiler warning that 'void value is not ignored as it should be.'

    So without more info, it is a bit hard to figure things out.

    A few things to keep in mind:

    • you can send commands to 'nil' in objc. So, if [foo add:pointer] returns nil, then you can call 'release' on it all day with no affect.

    • retainCount is your friend. You can call it on any NSObject to see how many objects are holding onto it. This may also help you track down the issue.

    • Finally, is Garbage Collection on?

提交回复
热议问题