Call a method from AppDelegate - Objective-C

前端 未结 3 1990
鱼传尺愫
鱼传尺愫 2021-02-19 13:10

I was trying to call an existing method of my ViewController.m from AppDelegate.m inside the applicationDidEnterBackground method,

3条回答
  •  情歌与酒
    2021-02-19 14:12

    The view controller is already instantiated as part of the NIB/storyboard process, so if your app delegate does its own alloc/init, you are simply creating another instance (which bears no relation to the one created the NIB/storyboard).

    The purpose of the construct you outline is merely to give the app delegate a reference to the view controller that the NIB/storyboard instantiated for you.

提交回复
热议问题