简体   繁体   English

“ AnyObject”与“ [NSObject:AnyObject]”不同

[英]'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.

相关问题 “ [NSObject:AnyObject]”与“ NSDictionary”不同,RKPathMatcher出现问题 - '[NSObject : AnyObject]' is not identical to 'NSDictionary', trouble with RKPathMatcher (NSObject,AnyObject)不能转换为DictionaryIndex <NSObject, AnyObject> - (NSObject, AnyObject) is not convertible to DictionaryIndex<NSObject, AnyObject> &#39;[NSObject]&#39; 不能转换为 &#39;[AnyObject]&#39; - '[NSObject]' is not convertible to '[AnyObject]' 在Swift中将[NSObject,AnyObject]转换为[String,AnyObject] - Converting [NSObject, AnyObject] to [String, AnyObject] in Swift Swift-[NSObject:AnyObject]! 不是“字典”的子类型 <String, AnyObject> - Swift - [NSObject : AnyObject]!' is not a subtype of 'Dictionary<String, AnyObject> [NSObject:AnyObject]和swift中的AnyObject有什么区别 - What is difference between [NSObject: AnyObject] and AnyObject in swift “字符串”与“ AnyObject”错误不同 - 'String' is not identical to 'AnyObject' error `NSDictionary`不能隐式转换为`[NSObject:AnyObject]` - `NSDictionary` is not implicitly convertible to `[NSObject : AnyObject]` Alamofire字符串与AnyObject错误不同 - Alamofire String is not identical to AnyObject error swift3中的编译错误:“ AnyObject”不是“ NSObject”的子类型 - Compilation error in swift3: 'AnyObject' is not a subtype of 'NSObject'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM