Why are subviews of an NSView not sent a release message when a Cocoa application terminates?

后端 未结 3 1234
礼貌的吻别
礼貌的吻别 2021-01-02 19:37

The short version:

  1. Why are the subviews of NSView objects not sent a release message when a Cocoa application terminates?
  2. I
3条回答
  •  走了就别回头了
    2021-01-02 20:05

    In the code you presented you are adding the subview to an ivar called 'view'. Is that what you really did or is it just from copying code to the question?

    I ask this because if I create an IBOutlet to the main window's content view and run your code it does what you say. But if I add the myView local var to parentView then it does deallocate:

    begin
    init 
    init 
    run
    quit
    dealloc 
    end
    dealloc  
    

    In addition it appears that sub views get autoreleased (adding a log message to autorelease proves it).

提交回复
热议问题