作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
尝试在 Swift 中实现这个 Objective C 代码:
// Whenever a person opens the app, check for a cached session
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// If there's one, just open the session silently, without showing the user the login UI
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:NO
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
[self sessionStateChanged:session state:state error:error];
}];
但是在这一行中 FBSession.activeSession.state.value 出现错误:
if FBSession.activeSession.state.value == FBSessionStateCreatedTokenLoaded.value {
FBSession.openActiveSessionWithReadPermissions(self.facebookReadPermissions, allowLoginUI: true, completionHandler: {(session, state, error) -> Void in
self.sessionStateChanged(session, state: state, error: error)
})
}
请帮忙。
最佳答案
用这个改变你的第一个 if 语句
if(FBSession.activeSession().state == FBSessionState.CreatedTokenLoaded)
{
}
关于ios - Facebook SDK FBSession 代码不适用于 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24995192/
我是一名优秀的程序员,十分优秀!