AFHTTPRequestOperationManager UI使用Swift冻结

时间:2014-06-09 21:17:57

标签: asynchronous afnetworking swift

我有一个问题,我正在使用AFNetworking和Swift做一个简短的例子,我看到我的用户界面在数据被下载时被冻结了..这是正常的吗?

这是我的代码

import UIKit

class ViewController: UIViewController {

    var manager:AFHTTPRequestOperationManager = AFHTTPRequestOperationManager()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func getJSON(sender : AnyObject) {
        manager.GET("https://itunes.apple.com/es/rss/topfreeapplications/limit=10/json", parameters: nil,
            success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
                println("JSON:  \(responseObject.description)")
            },
            failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
                println("Error:  \(error.localizedDescription)")
            })
    }

}

0 个答案:

没有答案