0

I am developing an iOS app that need to perform HTTP GET request to get JSON file every 10 seconds in the background.

I am using AFNetworking and I have already created a subclass of AFHTTPClient. Now it can get the JSON via HTTP GET request successfully, but I don't know how to let the HTTPClient get the JSON over and over in the background. My app need to update its UI with the information in the JSON.

4

1 回答 1

1

使用NSTimer

timer =[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(CallWebServiceMethod:) userInfo:nil repeats: YES];

你可以通过

 [myTimer invalidate];

还阅读文档https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSTimer_Class/Reference/NSTimer.html

于 2013-09-18T04:10:02.793 回答