[英]'AnyObject' is not identical to '[NSObject : AnyObject]'
I am finding this error in my AppDelegate.swift file and it appears in the AppDidFinishLaunchingWithOptions function. 我在AppDelegate.swift文件中发现此错误,它出现在AppDidFinishLaunchingWithOptions函数中。 It is raising the error on a line of code that is from the Parse framework. 它在来自Parse框架的代码行中引发错误。
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
The error is appearing on the launchOptions
parameter. 该错误出现在launchOptions
参数上。 I will post the whole function to show that it should be correct. 我将发布整个函数以表明它应该是正确的。 Also when I comment out the line of code the error disappears, but I still really want to be able to use the function and track the analytics. 同样,当我注释掉代码行时,错误消失了,但是我仍然非常希望能够使用该功能并跟踪分析。 Here is the whole function: 这是整个功能:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: AnyObject!) -> Bool
{
// Override point for customization after app launches
Parse.setApplicationId("removed on purpose", clientKey: "removed on purpose")
PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
PFFacebookUtils.initializeFacebook()
return true
}
I can't seem to find anything that relates to this error. 我似乎找不到任何与此错误相关的信息。 If anyone has some insight I would really appreciate it! 如果有人有见识,我将不胜感激!
Since Xcode 6 beta 7, when you want to call application:didFinishLaunchingWithOptions:
, you have to replace: 从Xcode 6 beta 7开始,当您要调用application:didFinishLaunchingWithOptions:
,必须替换:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
/* ... */
}
with the following code: 使用以下代码:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
/* ... */
}
The last parameter of this method is no more a NSDictionary but a Dictionary of type [NSObject: AnyObject]?
此方法的最后一个参数不再是NSDictionary,而是[NSObject: AnyObject]?
类型的Dictionary [NSObject: AnyObject]?
. 。 Therefore, you must update your code (including your trackAppOpenedWithLaunchOptions:
parameter type). 因此,您必须更新代码(包括您的trackAppOpenedWithLaunchOptions:
参数类型)。
The launchOptions
parameter should be declared as NSDictionary!
launchOptions
参数应声明为NSDictionary!
instead of AnyObject!
而不是AnyObject!
: :
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.