问题描述
我正在尝试将 facebook 登录集成到我的解析应用程序中.我遵循了解析教程中提到的每一步.在下面的代码中,我收到了编译错误.
I'm trying to integrate facebook login in my parse application. I followed every step mentioned in parse tutorial. In the below code, I'm getting compilation error.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
line1: Parse.setApplicationId("xxx", clientKey: "yyy")
line2: PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
line3: PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
line4: return true
}
在第 3 行,出现错误:
可选类型[NSObject:AnyObject]
"的值未解包;你是否意思是使用 '!
' 或 '?
'?
如果我使用 '!
' 手动解开它,因为 launchOptions 可以为零,我得到:
If I manually unwrap it using '!
', because launchOptions can be nil, I get:
致命错误:解包可选值时意外发现 nil
如果我检查 nil,我得到:
If I check for nil, I get:
NSInternalInconsistencyException
',原因:'你必须初始化PFFacebookUtils 调用+initializeFacebookWithApplicationLaunchOptions
知道如何修复它吗?
推荐答案
这是 ParseSDK 中的一个错误.在 Parse 解决此问题之前,您可以更改 PFFacebookUtils.h 头文件中的初始化函数声明
It is a bug in ParseSDK. Until Parse fix this you can change the initialize function declaration at PFFacebookUtils.h header file
1) 转到 PFFacebookUtils.h
1) Go to PFFacebookUtils.h
2) 改变:
- (void)initializeFacebookWithApplicationLaunchOptions:(NSDictionary *)launchOptions;
致:
- (void)initializeFacebookWithApplicationLaunchOptions:(PF_NULLABLE NSDictionary *)launchOptions;
此答案由 Kiarash Akhlaghi 在 https://developers.facebook.com/bugs/1462780714012820/ 提供
This answer was provided by Kiarash Akhlaghi at https://developers.facebook.com/bugs/1462780714012820/
这篇关于PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions) 给出编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!