Эти две проблемы меня беспокоят
Он выполнит первые две строки, а затем вернет
Почему код Alamofire задерживается
func reqestFoodImage(foodName:String) -> UIImage{
let newFoodName = foodName.replacingOccurrences(of: " ", with: "_")
let url = serverIP + "/sendImage/" + newFoodName
var returnImage:UIImage = UIImage()
Alamofire.request(url, method: .get).responseImage{responed in
if let image = responed.result.value{
returnImage = image
}
else{
print("image requset fail")
}
}
return returnImage
}
Проблемы 2:
Почему перфоманс не работает
@IBAction func loginWithFacebook(_ sender: UIButton) {
let loginManager = LoginManager()
loginManager.logIn(permissions: [ .publicProfile,.email ], viewController: self) { loginResult in
print(loginResult)
switch loginResult{
case .failed(let error):
print("facebook login error = \(error)")
case .cancelled:
print("facebook login cancelled")
case .success(granted: let grantdePermission, declined: let declindePermission, token: let accessToken):
print("facebook login success")
self.getFacebookDetails()
DispatchQueue.main.async{
print("doing degue")
self.performSegue(withIdentifier: "loginGoToHome", sender: self)
}
}
}
}