Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在UITableView中显示RestKit提要_Ios_Objective C_Restkit - Fatal编程技术网

Ios 在UITableView中显示RestKit提要

Ios 在UITableView中显示RestKit提要,ios,objective-c,restkit,Ios,Objective C,Restkit,您好,我正在尝试在tableview中显示从open weather API提取的结果,我的请求显示了结果,但我不知道如何在tableview中显示此结果 - (void)viewDidLoad { [self getWeatherForCity:@"London"]; [super viewDidLoad]; } -(RKResponseDescriptor *)responseDescriptor { RKObjectMapping* cloudMapping =

您好,我正在尝试在tableview中显示从open weather API提取的结果,我的请求显示了结果,但我不知道如何在tableview中显示此结果

- (void)viewDidLoad {
    [self getWeatherForCity:@"London"];
    [super viewDidLoad];
}

-(RKResponseDescriptor *)responseDescriptor {

    RKObjectMapping* cloudMapping = [RKObjectMapping mappingForClass:[Clouds class]];
    [cloudMapping addAttributeMappingsFromArray:@[@"all"]];
    RKObjectMapping* coordMapping = [RKObjectMapping mappingForClass:[Coord class]];
    [coordMapping addAttributeMappingsFromArray:@[@"lon",@"lat"]];
    RKObjectMapping* weatherReportMapping = [RKObjectMapping mappingForClass:[WeatherReport class]];
    [weatherReportMapping addAttributeMappingsFromArray:@[@"name"]];

    [weatherReportMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"clouds"
                                                                                         toKeyPath:@"clouds"
                                                                                       withMapping:cloudMapping]];

    [weatherReportMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"coord"
                                                                                         toKeyPath:@"coord"
                                                                                       withMapping:coordMapping]];

    RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:weatherReportMapping
                                                                                            method:RKRequestMethodAny
                                                                                       pathPattern:nil
                                                                                           keyPath:nil
                                                                                       statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
    return responseDescriptor;
}

-(void)getWeatherForCity:(NSString *)cityName{

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://api.openweathermap.org/data/2.5/weather?q=%@",cityName]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    RKObjectRequestOperation *objectRequestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request
                                                                                     responseDescriptors:@[[self responseDescriptor]]];

    [objectRequestOperation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
        //RKLogInfo(@"Load collection of Weather: %@", mappingResult.array);
        RKLogInfo(@"Load collection of Weather: %@", mappingResult.array);

    } failure:^(RKObjectRequestOperation *operation, NSError *error) {

        RKLogError(@"Operation failed with error: %@", error);
    }];

    [objectRequestOperation start];
}

有人能告诉我如何使用提要推断并返回tableview中正确的行数,以及如何将
cell.textlab.text
设置为提要中的某个内容吗?

下面是一个使用带有数组的table view的教程-

您可以使用以下教程参考UITableView中的Restkit提要-


建议:在这里提问之前,请先对谷歌进行基础研究。

您是否搜索过使用带数组的表视图的教程?您已经完成了困难的部分…我是否需要将映射添加到数组中,然后在tableview中显示它们,或者从我现在所在的位置直接将它们放入tableview中?