本地快速開發的新手! 打開下面的問題https://github.com/forcedotcom/SalesforceMobileSDK-iOS/issues/2072構建失敗:可選類型'[SFUserAccount]?'的值不解開
移動SDK的版本中使用:5.1.0
問題在本機應用程序或應用混合發現:原生應用
OS版本:10.12.5
設備:iPhone 6
重現步驟:
-
個
- forceios創建
- 提供的應用程序類型爲
native_swift
並添加其他所需的詳細信息 - 打開
*.xcworkspace
文件在Xcode - 生成項目
錯誤:Value id optional type '[SFUserAccount]?' not unwrapped;
func handleSdkManagerLogout()
{
self.log(.debug, msg: "SFAuthenticationManager logged out. Resetting app.")
self.resetViewState {() ->() in
self.initializeAppViewState()
// Multi-user pattern:
// - If there are two or more existing accounts after logout, let the user choose the account
// to switch to.
// - If there is one existing account, automatically switch to that account.
// - If there are no further authenticated accounts, present the login screen.
//
// Alternatively, you could just go straight to re-initializing your app state, if you know
// your app does not support multiple accounts. The logic below will work either way.
var numberOfAccounts : Int;
let allAccounts = SFUserAccountManager.sharedInstance().allUserAccounts()
numberOfAccounts = (allAccounts!.count);
if numberOfAccounts > 1 {
let userSwitchVc = SFDefaultUserManagementViewController(completionBlock: {
action in
self.window!.rootViewController!.dismiss(animated:true, completion: nil)
})
if let actualRootViewController = self.window!.rootViewController {
actualRootViewController.present(userSwitchVc!, animated: true, completion: nil)
}
} else {
if (numberOfAccounts == 1) {
SFUserAccountManager.sharedInstance().currentUser = allAccounts[0]
// ERROR: Value id optional type '[SFUserAccount]?' not unwrapped;
}
SalesforceSDKManager.shared().launch()
}
}
}
什麼是鏈接器錯誤?您可以從左側面板複製粘貼。 – deadbeef
請不要張貼代碼的截圖。改爲發佈實際的代碼。 – Dima
鏈接器錯誤可能只是Xcode壞了。清理生成文件夾,它應該工作。 –