所以我更新了Xcode并得到了一堆很容易修复的错误但是在更新了FBSDK之后,我的AppDelegate出现了一个错误,我似乎无法修复:
/Users/wylerzahm/Desktop/AppName/AppName/AppDelegate.swift:23:58: Cannot invoke 'application' with an argument list of type '(UIApplication, openURL: NSURL?, sourceApplication: NSString?, annotation: [NSObject : AnyObject]?)'
给出错误的实际功能如下:
func application(application: UIApplication, openURL url: NSURL?, sourceApplication: NSString?, annotation: [NSObject: AnyObject]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
此功能是Facebook登录工作所必需的。任何帮助表示赞赏。 被调用的函数如下:
@interface FBSDKApplicationDelegate : NSObject
+ (instancetype)sharedInstance;
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
请有人帮忙!
答案 0 :(得分:7)
我在使用Swift 1.2升级到XCode 6.3之后也遇到了这个问题。
问题似乎是sourceApplication类型已在函数中从NSString
更新为String
:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: NSString?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
所以它应该是:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
干杯!
编辑:正如Ruud Kalis所述,注释类型也从AnyObject
更新为AnyObject?
答案 1 :(得分:1)
另请注意从AnyObject
到AnyObject?
的更改。如果没有改变,编译器仍然会抱怨。