2014-09-27 50 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