几天以来,我试图打印来自数据数组的两个字符串,这些字符串是从来自我的服务器的 xml 文件中解析的(很长:D)。问题是我只设法打印了两个字符串之一。我进行了研究并找到了有关技术的指针,但是如果有人可以帮助我,我将无法使该技术发挥作用。这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
for(UIView *eachView in [cell subviews]){
[eachView removeFromSuperview];
}
UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectZero];
[lbl1 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl1 setTextColor:[UIColor grayColor]];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
lbl1.text = [[stories objectAtIndex: storyIndex] objectForKey: @"creation_date"];
NSLog(lbl1.text);
[cell addSubview:lbl1];
[lbl1 release];
UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectZero];
[lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl2 setTextColor:[UIColor blackColor]];
lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"name"];
NSLog(lbl2.text);
[cell addSubview:lbl2];
[lbl2 release];
//Used to do this ---> int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
//[cell.textLabel setText:[[stories objectAtIndex: storyIndex] objectForKey: @"creation_date"]];
return cell;
}