What is “super” in Objective-C? ( self != super )?

前端 未结 1 1398
无人及你
无人及你 2021-02-08 23:44

I\'ve read the question below, and the story SEEMS simple:

What exactly is super in Objective-C?

Yet ...

- (id) init
{
    NSLog(@\"self         


        
相关标签:
1条回答
  • 2021-02-08 23:49

    You are messing with the man behind the curtain and he is punishing you for it... :)

    super is a bit of compiler magic, really. When you say [super doSomething], the compiler will emit a call to objc_msgSendSuper() instead of objc_msgSend(). Most of the time -- there are some special cases.

    In general, you should treat super as only a target for method calls. It should never be stored anywhere and should never be considered anything but that target expression for messaging.

    In fact, uses of super that involve storage should likely be flagged by the compiler.

    In terms of your bug, that sounds an awful lot like there is either corruption of memory, an over-release, and/or concurrency going on. You'll need to provide more code related to the enumeration and other relevant code to deduce further.

    0 讨论(0)
提交回复
热议问题