¿Cómo devuelvo algo de AlamoFire?
import Foundation
import Alamofire
import UIKit
import SwiftyJSON
class APIClient: UIViewController {
let loggedIn = false
struct Constants{
static let Domain = "http://gogogo.com"
}
func authenticate() -> Bool{
println("Authenticating")
if let access_token = FBSDKAccessToken.currentAccessToken().tokenString {
let parameters = [ "access_token": access_token ]
Alamofire.request(.POST, Constants.Domain+"/accounts", parameters: parameters).responseJSON {
(req, res, json, error) in
if(error != nil) {
self.sendReturnToSplash()
} else {
let json = JSON(json!)
println("\(json)")
return true //This doesn't work!!!!!!
}
}
}else{
println("No access token to authenticate")
}
}
func sendReturnToSplash(){
let center = NSNotificationCenter.defaultCenter()
let notification = NSNotification(name: NotificationCenters.ReturnToSplash, object: self, userInfo: ["":""])
center.postNotification(notification)
}
}
Como puede ver, si el cierre de sesión es exitoso, quiero devolver "verdadero". Sin embargo, XCode me da un "vacío no se ajusta al protocolo BooleanLiteral"