开发者

Problems with InitWithData

开发者 https://www.devze.com 2023-03-15 07:36 出处:网络
I am trying to InitWithData a viewcontroller with multiple data like this: NewsDetailViewController *anotherViewController = [[NewsDetailViewController alloc]initWithData:[oldEntries objectAtIndex:i

I am trying to InitWithData a viewcontroller with multiple data like this:

 NewsDetailViewController *anotherViewController = [[NewsDetailViewController alloc]      initWithData:[oldEntries objectAtIndex:indexPath.row]];
 [self.navigationController pushViewController:anotherViewController animated:YES];
 [anotherViewController release];   
 [newsTableView deselectRowAtInde开发者_如何学CxPath:indexPath animated:NO];  

So this is the current: InitWithData:initWithData:[oldEntries objectAtIndex:indexPath.row]];

Now I need the InitWithData to push 2 of these objects:

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

How can I do this?

I receive the current data like this in the NewsDetailController:

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

    }
    return self;
}

And rssData is a NSDictionary..


change your init method to

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

and call it using

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

Of course you need to declare rssOldDataand rssReviewData in your NewsDetailViewController too.

0

精彩评论

暂无评论...
验证码 换一张
取 消