let user = "Pep" let Password = "password" let urlPath: String = "http://www.theclubgate.com/mobileapp/login.php" var url: NSURL = NSURL(string: urlPath)! var request1: NSMutableURLRequest = NSMutableURLRequest(URL: url) request1.HTTPMethod = "POST" var stringPost = "password=\(user)&page_type=login&emailoruser=\(Password)" let data = stringPost.dataUsingEncoding(NSUTF8StringEncoding) request1.timeoutInterval = 60 request1.HTTPBody=data request1.HTTPShouldHandleCookies=false let queue:NSOperationQueue = NSOperationQueue() NSURLConnection.sendAsynchronousRequest(request1, queue: queue, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in println("AsSynchronous #\(data)") let Clubdata = NSString(data: data, encoding: NSUTF8StringEncoding); println("AsSynchronous\(Clubdata)") var err: NSError? var jsonResult: NSMutableArray = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSMutableArray println("AsSynchronous#\(jsonResult)!") var JsonArray : NSMutableArray = jsonResult as NSMutableArray println("AsSynchronous#\(JsonArray)!") })
答案 0 :(得分:2)
我假设您在获得响应数组后想要执行某些操作。 所以添加
dispatch_async(NSOperationQueue .mainQueue(), { () -> Void in
// call your own method with array parameter
});
低于println("AsSynchronous#\(JsonArray)!")
使用Array参数实现自己的方法并在那里做你的东西。祝你好运