我一直試圖把我的數組的值放在我的表格視圖單元格中,這是多維數組我應該怎麼做?如何把數組元素放在一個表格視圖單元格
這裏有一個解析器類
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"subsidiary"])
{
NSLog(@"%i", [app.infoarray count]);
[app.listArray addObject:app.infoarray];
[app.infoarray removeAllObjects];
}
else
{
if ([elementName isEqualToString:@"countryname"])
{
temp = currentElementValue;
}
if ([elementName isEqualToString:@"name"])
{
theList.name = currentElementValue;
[app.infoarray addObject:theList.name];
}
if ([elementName isEqualToString:@"address"])
{
theList.address = currentElementValue;
[app.infoarray addObject:theList.address];
}
下面的代碼是mainviewcontroller
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
theList.countryname = [app.listArray objectAtIndex:0];
cell.textLabel.text= theList.countryname; ////<<WHAT SHOULD I DO HERE?
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
我只想cell.textlabel顯示國名 我在短短的新目標c我希望有人能幫助我
構建成功,但它不顯示任何東西 –
@ Tbt-lionArmanCapistrano:你用過tableview委託嗎? NSlog(@「%@」,[theList.countryname]); – iAppDeveloper
它是空的,在List.countryname中沒有值。我該怎麼辦? –