我是否需要 ApplicationDelegate 函数中的 UIApplication* 应用程序?

Will I ever need the UIApplication* application from the ApplicationDelegate functions?

任何应用程序委托中的应用程序参数何时不等于共享实例?

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{  
  UIApplication* sharedapp = [UIApplication sharedApplication];
  if(application == sharedapp){
    //things are as I expect
  }else{
    //some other situation I can't think of
  }
}

不,不会有那样的情况。

来自文档:

Every app has exactly one instance of UIApplication. When an app is launched, the system calls the UIApplicationMain function; among its other tasks, this function creates a singleton UIApplication object. Thereafter you access the object by calling the sharedApplication class method.

[UIApplication sharedApplication] 的调用将始终 return 指向您应用程序的共享应用程序对象的指针。这就是该方法的用途。

您要比较的变量 sharedApp 是什么?大概这是一个实例变量,您定义并设置为包含指向您的应用程序对象的指针,并使用与 [UIApplication sharedApplication]?

相同的调用