Hi there i am currently working on a Api Manager in Swift, what i got so far:
import Foundation
import CoreData
import Alamofire
import SwiftyJSON
class ApiManager {
var data: NSArray = []
func getApi() -> NSArray {
let user:String = "user"
let password:String = "password"
Alamofire.request(.GET, "http://localhost/api/")
.authenticate(user: user, password: password)
.responseJSON{ (request, response, jsonData, error) in
if let jsonData1 = jsonData {
if let jsonData2 = JSON(jsonData1).dictionaryObject {
self.data = jsonData2["data"] as! NSArray
}
}
}
return data
}
}
The JSON Api is correct, but there is something wrong with my swift code, but i am not sure what it is,
When i call this manager:
let response = ApiManager().getApi()
println(response)
I just get empty brackets:
(
)
Anybody could help me with this?