我有一个名为 SecondViewController 的视图控制器,当用户选择要阅读的文章时,我想导航到 ThirdViewController 并使用文章数据传递 NSDictionary。
- (void) touchButtonBlock:(NSInteger) select
{
NSLog(@"touchButtonBlock");
NSDictionary *dict;
switch (select) {
case 0:
{
NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] init];
NSMutableDictionary *val = [[NSMutableDictionary alloc] init];
[val setObject:@"article360.html" forKey:@"page"];
[val setObject:@"img.png" forKey:@"img"];
[val setObject:@"art1" forKey:@"name"];
[tmpDict setObject:val forKey:[NSNumber numberWithInt:0]];
val = [[NSMutableDictionary alloc] init];
[val setObject:@"article360.html" forKey:@"page"];
[val setObject:@"img.png" forKey:@"img"];
[val setObject:@"art2" forKey:@"name"];
[tmpDict setObject:val forKey:[NSNumber numberWithInt:1]];
dict = [NSDictionary dictionaryWithDictionary:tmpDict];
//[tmpDict release];
//[val release];
break;
}
NSDictionary *immDict = [NSDictionary dictionaryWithDictionary:dict];
ArticleSelectListViewController *selectorView = [[ArticleSelectListViewController alloc] initWithArticlesData:immDict];
[self.navigationController pushViewController:selectorView animated:YES];
[selectorView release];
}
在这里,我评估 NSDictionary:
- (id)initWithArticlesData:(NSDictionary *)data
{
self = [super initWithNibName:nil bundle:nil];
if (self)
{
articles = data;
...
}
但是在用户交互之后调用的其他函数中,articles 变量似乎不正确 - 它不包含我的数据。
我在哪里犯错?