从数组中检索文本

时间:2014-09-09 22:13:08

标签: ios nsarray

我正在开发一个应用程序,我将查询发送到网页并获取信息并将其保存到我的数组中。现在,所有这些工作除了那时我来从我的数组中获取值并在我的文本视图中显示它。使用此代码

-(void)viewDidAppear:(BOOL)animated
{

 self.tvSoilN.text  = [[_soilNotes objectAtIndex:0] objectForKey:@"crop"];
}

但是,我得到数组的错误是空的。 现在这是有道理的,因为使用断点我可以看到上面的代码实际运行之前代码在我的model.m文件中,我用它来编写数组中的数据

我无法发布图片,但是当我在if(self.delegate)行使用断点时它会显示给我 _locations(当我向下看时,我看到) _crop_soil(这是我数据库中的字段)= @" Blah blah blah") 这让我意识到我的数据确实正在从网上转发。但我只是难以从我的阵列或任何地方显示它。 想要一些帮助,特别是在哪里调用我的阵列,因为我也认为我做错了。谢谢你

IN实施文件

-(void)itemsDownloaded:(NSArray *)items
{
    // This delegate method will get called when the items are finished downloading

    // Set the downloaded items to the array
    _soilN = items;



    NSLog(@"soil%@",_soilNotes);
    self.tvSoilN.text=[[_soil objectAtIndex:0]objectForKey:@"crop"];
}

1 个答案:

答案 0 :(得分:0)

使用valueForKey而不是objectForKey。最后到达那里!