InitWithData的问题

时间:2011-06-24 09:01:24

标签: iphone objective-c

我正在尝试使用如下多个数据的initWithData视图控制器:

 NewsDetailViewController *anotherViewController = [[NewsDetailViewController alloc]      initWithData:[oldEntries objectAtIndex:indexPath.row]];
 [self.navigationController pushViewController:anotherViewController animated:YES];
 [anotherViewController release];   
 [newsTableView deselectRowAtIndexPath:indexPath animated:NO];  

所以这是当前的:InitWithData:initWithData:[oldEntries objectAtIndex:indexPath.row]];

现在我需要InitWithData来推送其中两个对象:

[oldEntries objectAtIndex:indexPath.row];
[reviewEntries objectAtIndex:indexPath.row];

我该怎么做?

我在NewsDetailController中收到了这样的当前数据:

- (id)initWithData:(NSDictionary *)data {
    if (self == [super init]) {        
    rssData = [data copy];  

    }
    return self;
}

rssData是一个NSDictionary ..

1 个答案:

答案 0 :(得分:1)

将您的init方法更改为

 - (id)initWithOldData:(NSDictionary *)oldData 
       andReviewData:(NSDictionary *)revData {
  if (self == [super init]) {        
  rssOldData = [oldData copy];  
  rssReviewData = [revData copy]; 
  }
  return self;
}

并使用

调用它
[[NewsDetailViewController alloc] 
 initWithOldData:[oldEntries objectAtIndex:indexPath.row] 
 andReviewData:[reviewEntries objectAtIndex:indexPath.row]];

当然,您还需要在rssOldData中声明rssReviewDataNewsDetailViewController