0
我有一個代碼,一旦應用程序正在運行請求。我的問題是我如何每5秒發出一次請求?有史以來5秒的安靜請求
代碼:
NSDictionary* headers = @{@"X-Mashape-Authorization": @"Key"};
NSDictionary* parameters = @{};
UNIHTTPJsonResponse* response = [[UNIRest get:^(UNISimpleRequest* request) {
[request setUrl:@"https://willjw-statsfc-competitions.p.mashape.com/live.json?key=free&competition=premier-league&timezone=Europe%2FLondon"];
[request setHeaders:headers];
[request setParameters:parameters];
}] asJson];
NSData* rawBody = [response rawBody];
results = [NSJSONSerialization JSONObjectWithData:rawBody options:NSJSONReadingMutableContainers error:nil];
NSLog(@"%@", results);
for (int i = 0; i <= results.count-1; i++)
{
NSString *homeTeam = [[results valueForKey:@"homeshort"] objectAtIndex:i ];
NSString *awayTeam = [[results valueForKey:@"awayshort"] objectAtIndex:i ];
NSString *time = [[results valueForKey:@"statusshort"] objectAtIndex:i ];
NSString *homeScore = [NSString stringWithFormat:@"%@", [[[results valueForKey:@"runningscore"] objectAtIndex:i ] objectAtIndex:0]];
NSString *awayScore = [NSString stringWithFormat:@"%@", [[[results valueForKey:@"runningscore"] objectAtIndex:i ] objectAtIndex:1]];
[arrayBarclay addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:homeTeam,@"hometeam", awayTeam,@"awayteam", time, @"time", homeScore, @"homescore", awayScore, @"awayscore", nil]];
}