2014-09-27 20 views
1

我有一個應用程序當前正在使用AFNetworking 1.0來同步來自REST Web服務的數據。如何在後臺線程上使用AFNetworking?

噹噹前通過點擊UI上的按鈕發生同步時,它會阻止用戶界面。

我正在升級應用程序以使用AFNetworking 2.0。

如何讓後臺線程發生同步,以便UI不會停頓?

+0

沒有幫助,這了嗎? – motionpotion 2014-11-12 18:32:28

+0

請顯示您的代碼 – sage444 2015-01-20 14:49:12

回答

0

你試試這個:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://gowalla.com/users/mattt.json"]]; 
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { 
    NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]); 
} failure:nil]; 

查看以下鏈接 https://github.com/AFNetworking/AFNetworking/wiki/Introduction-to-AFNetworking