ARC seems to be releasing the view of my NSViewController

后端 未结 2 1099
借酒劲吻你
借酒劲吻你 2021-01-28 06:11

I am trying to solve a larger problem and I am tipping on the fact that ARC apparently is releasing the view to my NSViewController too early. I think :) So I created a simple a

2条回答
  •  不知归路
    2021-01-28 06:52

    You need to add an ivar or property to hold the TextViewController. Currently, the only reference to it is going away at the end of applicationDidFinishLaunching: which causes it to be deallocated.

    That's bad, because your button needs the controller to be around to handle the button press. The view doesn't hold on to it's controller, as that would cause a retain cycle. So you are responsible for keeping the controller around if you don't want your button talking to a deallocated object.

提交回复
热议问题