0

私は次のウェブサービスを持っています。

"club": {

    "staff": [ … ],
    "trainingen": [ … ],
    "team": [
        {
            "name": "Baerts Lennert",
            "number": "0",
            "position": "Doelman",
            "birthdate": "1996-09-01",
            "red_cards": 0,
            "yellow_cards": 0,
            "news": [
                {
                    "nid": "1158",
                    "player_id": 1
                },
                {
                    "nid": "1148",
                    "player_id": 1
                },

            ]
        },

私は次の方法でこれを取得しています。

+ (NSArray *)getPlayNewsWithIndex:(int)index
{
    NSLog(@"index is hier %d",index);
    NSString *request = [NSString stringWithFormat:@"http://www.krcgenk.be/mobile/json/request/club/type/ipad"];
    NSLog(@"log1");
    NSArray *arr = [[self executeGenkFetch:request] valueForKeyPath:@"club.team"];
    NSLog(@"log2");
    NSArray *arr2 = [[arr objectAtIndex:index] valueForKey:@"news"];
    NSLog(@"log3");
    return arr2;
}

「log1」をログに記録した後。機能が継続するまでしばらく時間がかかります。私の質問は今、どのようにこれが可能ですか?

編集

これは私のexecuteGenkFetchです

+ (NSDictionary *)executeGenkFetch:(NSString *)query
{
    query = [NSString stringWithFormat:@"%@", query];
    query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    // NSLog(@"[%@ %@] sent %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), query);
    NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
    NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;
    if (error) NSLog(@"[%@ %@] JSON error: %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), error.localizedDescription);
    // NSLog(@"[%@ %@] received %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), results);
    return results;
}
4

0 に答える 0