zac*_*zac 2 arrays dictionary objective-c tableview ios
现在我宣布:
NSMutableArray *feeds;
NSMutableString* Severity;
NSMutableString* incidentNumber;
NSMutableDictionary *IncidentGetList;
Run Code Online (Sandbox Code Playgroud)
我已成功从XMLParser中检索出数据,日志中的数据如下所示:
Final Feed : (
{
code = 80180058;
Severity = Warning;
},
{
code = 80167359;
color = red;
},
{
code = 80143253;
color = green;
},
{
code = 80118575;
color = blue;
},
{
code = 80114765;
color = yellow;
}
)
Run Code Online (Sandbox Code Playgroud)
问题是我如何在ONE CELL中显示这两个Mutable字符串.这意味着表视图中的每个单元格显示代码:12345和颜色:黄色.
以下是我在表格视图中的代码:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [feeds count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = [[feeds objectAtIndex:indexPath.row]objectForKey:@"color"];
cell.textLabel.text = [[feeds objectAtIndex:indexPath.row] objectForKey:@"code"];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
您可以将这两个值组合成一个字符串然后显示.例如:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = [NSString stringWithFormat:@"Code : %@ , Color : %@",[[feeds objectAtIndex:indexPath.row] objectForKey:@"code"],[[feeds objectAtIndex:indexPath.row]objectForKey:@"color"] ];
return cell;
}
Run Code Online (Sandbox Code Playgroud)