在以下方法中,参数声明中的launchOptions
是什么?它是NSObject类型数组的可选项吗?我对swift很新,所以听起来很傻,但我不明白didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?
的含义。非常感谢任何帮助:)
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame:UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.makeKeyAndVisible()
return true
}
答案 0 :(得分:1)
这是swift翻译NSArray的方式。
Array类型和NSArray类之间的Swift桥接。从NSArray对象桥接到Swift数组时,生成的数组的类型为[AnyObject]。如果对象是Any-Object兼容的,如果它是Objective-C或Swift类的实例,或者该对象可以桥接到一个对象。您可以将任何NSArray对象桥接到Swift数组,因为所有Objective-C对象都是AnyObject兼容的。因为所有NSArray对象都可以桥接到Swift数组,所以Swift编译器在导入Objective-C API时用[AnyObject]替换NSArray类
答案 1 :(得分:0)
表示应用程序启动原因的字典(如果有)。在用户直接启动应用程序的情况下,此词典的内容可能为空。有关此词典中可能的键以及如何处理它们的信息,请参阅启动选项键。
可能的关键:
UIApplicationLaunchOptionsURLKey:String UIApplicationLaunchOptionsSourceApplicationKey:String UIApplicationLaunchOptionsRemoteNotificationKey:String UIApplicationLaunchOptionsAnnotationKey:String UIApplicationLaunchOptionsLocalNotificationKey:String UIApplicationLaunchOptionsLocationKey:String UIApplicationLaunchOptionsNewsstandDownloadsKey:String UIApplicationLaunchOptionsBluetoothCentralsKey:String UIApplicationLaunchOptionsBluetoothPeripheralsKey:String UIApplicationLaunchOptionsUserActivityDictionaryKey:String UIApplicationLaunchOptionsUserActivityTypeKey:String