0
我解析一個包含三個標籤的json提要,它們是Name,Status,Image,並將它存儲在一個NSMutableArray.if中,如果我的「status」爲「1」,我必須返回數據對應於大括號內的「Name」標記並將其填充到我的表視圖中。問題是如果它的true.im能夠返回唯一的值並且填充下面的整個tableview,那麼就是json結構,代碼和屏幕截圖。如何提取特定的值並填充到tableview中
JSON結構
{
Image = "http://dev-parkguiden.knutpunkten.se/Content/Images/Icons/icon8.png";
Name = "Caf\U00e9/restaurang";
Status = 0;
},
{
Image = "http://dev-parkguiden.knutpunkten.se/Content/Images/Icons/icon9.png";
Name = "Kiosk ";
Status = 0;
},
{
Image = "http://dev-parkguiden.knutpunkten.se/Content/Images/Icons/icon10.png";
Name = "Toalett finns";
Status = 1;
},
{
Image = "http://dev-parkguiden.knutpunkten.se/Content/Images/Icons/icon11.png";
Name = "Parkeringsm\U00f6jligheter";
Status = 1;
},
{
Image = "http://dev-parkguiden.knutpunkten.se/Content/Images/Icons/icon1.png";
Name = Minigolf;
Status = 1;
},
XCODE
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
for (int i=0; i<[self.media1 count]; i++)
{
NSDictionary *boy=[self.media1 objectAtIndex:i];
NSString *str=[[NSString alloc]initWithFormat:@"%@",boy];
//NSLog(@"the value:%@",str);
if([str isEqualToString:@"1"])
{
//NSDictionary *hai=[[boy objectAtIndex:indexPath.row]objectForKey:@"1"];
// NSLog(@"the values availbale:%@",hai);
cell.textLabel.text=[self.story objectAtIndex:i];
return cell;
}
}
是der獲得整個value.if我可以在表視圖之外使用它的任何可能性? – kingston 2012-02-09 12:21:19
是的只是在for循環中創建一個新數組。但出側桌視圖後,新陣列然後重新加載表新陣列 – Hiren 2012-02-09 12:24:49
k將嘗試 – kingston 2012-02-09 12:30:51