[英]PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions) giving compilation error
I'm trying to integrate facebook login in my parse application. 我正在尝试将facebook登录集成到我的解析应用程序中。 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
}
In line 3 , I'm getting error: 在第3行 ,我收到错误:
Value of optional type '
[NSObject:AnyObject]
' not unwrapped; 可选类型'[NSObject:AnyObject]
'的值[NSObject:AnyObject]
包; did you mean to use '!
你的意思是用'!
' or '?
'或'?
'? “?
If I manually unwrap it using ' !
如果我使用'手动打开它!
', because launchOptions can be nil, I get: ',因为launchOptions可能是零,我得到:
Fatal error: unexpectedly found nil while unwrapping an Optional value 致命错误:在展开Optional值时意外发现nil
If I check for nil, I get: 如果我检查无,我得到:
NSInternalInconsistencyException
', reason: 'You must initialize PFFacebookUtils with a call to+initializeFacebookWithApplicationLaunchOptions
NSInternalInconsistencyException
',原因:'你必须通过调用+initializeFacebookWithApplicationLaunchOptions
初始化PFFacebookUtils
Any idea how to fix it? 知道怎么解决吗?
It is a bug in ParseSDK. 这是ParseSDK中的一个错误。 Until Parse fix this you can change the initialize function declaration at PFFacebookUtils.h header file 在Parse修复此问题之前,您可以在PFFacebookUtils.h头文件中更改初始化函数声明
1) Go to PFFacebookUtils.h 1)转到PFFacebookUtils.h
2) change: 2)改变:
To: 至:
This answer was provided by Kiarash Akhlaghi at https://developers.facebook.com/bugs/1462780714012820/ 这个答案由Kiarash Akhlaghi提供,网址是https://developers.facebook.com/bugs/1462780714012820/
The problem was a bug of ParseSDK, it does not accept nil launchOptions 问题是ParseSDK的一个错误,它不接受nil launchOptions
According to the the answer provided by Roger Ingouacka at https://developers.facebook.com/bugs/1462780714012820/ 根据Roger Ingouacka在https://developers.facebook.com/bugs/1462780714012820/提供的答案
if let launchOptions = launchOptions {
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
} else {
PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions([NSObject:AnyObject]())
}
Notice the use of 注意使用
[NSObject:AnyObject]()
This problem persisted untill I updated to Parse library 1.8.1 . 这个问题一直存在,直到我更新到Parse库1.8.1 。
I tried adjusting PFFacebookUtils.h, and a lot of other things, but that did not solve it. 我尝试调整PFFacebookUtils.h以及其他很多东西,但这并没有解决它。 It was driving me insane. 这让我疯了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.