-2

self.weatherData をチェックすると、「data」にデータがあるのに何も出てこない。これが私の機能です:

- (void)handleNetworkResponse:(NSData *)myData
{
    //NSMutableDictionary *data = [NSMutableDictionary dictionary];
    NSMutableDictionary *data = [[NSMutableDictionary alloc] init];

    // now we'll parse our data using NSJSONSerialization
    id myJSON = [NSJSONSerialization JSONObjectWithData:myData options:NSJSONReadingMutableContainers error:nil];

    // typecast an array and list its contents
    NSDictionary *jsonArray = (NSDictionary *)myJSON;

    // take a look at all elements in the array
    for (id element in jsonArray) {

        id key = [element description];

        id innerArr = [jsonArray objectForKey:key];

        NSDictionary *inner = (NSDictionary *)innerArr;

        if ([inner conformsToProtocol:@protocol(NSFastEnumeration)]) {

            for(id ele in inner) {

                id innerKey = [ele description];
                [data setObject:[[inner valueForKey:innerKey] description] forKey:[ele description]];
            }
        }
        else {

            [data setObject:[inner description] forKey:[element description]];
        }
    }

    NSLog([data description]);
    self.weatherData = data;
}

しかし、self.weatherDataをチェックすると、「data」にデータがあるのに何も出てこない。

4

1 に答える 1

0

問題は、非同期メソッドから変数に割り当てるときにデータが存在しないことでした:Dデリゲートコールバックを追加することですべて修正されました

于 2013-08-29T22:48:52.923 に答える