您好我有一个分组的tableview第一部分包含电子邮件列表,第二部分只有两行手动添加电子邮件并从联系人中选择电子邮件。
ManualEmail.m中的日志保持记录0的计数,并且EmailViewController中的数组永远不会被修改,但我无法弄清楚出了什么问题
这是我目前的设置
EmailViewController.h
@property (nonatomic, retain) IBOutlet NSMutableArray *dataArray;
EmailViewController.m
@synthesize dataArray;
- (void)viewDidLoad {
[super viewDidLoad];
dataArray = [[NSMutableArray alloc] init];
NSMutableArray *listItems = [[NSMutableArray alloc] initWithObjects:nil];
[listItems addObject:[ObjectArrays productWithType:@"test" Eemail:@"test@website.com" Eselected:YES]];
NSDictionary *firstItemsArrayDict = [NSDictionary dictionaryWithObject:listItems forKey:@"data"];
[dataArray addObject:firstItemsArrayDict];
NSArray *secondItemsArray = [[NSArray alloc] initWithObjects:@"Add Email Address From Contacts", @"Add Email Address Manually", nil];
NSDictionary *secondItemsArrayDict = [NSDictionary dictionaryWithObject:secondItemsArray forKey:@"data"];
[dataArray addObject:secondItemsArrayDict];
[tableView reloadData];
}
ManualEmail.m
EmailViewController *emailPVC = [[EmailViewController alloc] init];
NSDictionary *dictionary = [emailPVC.dataArray objectAtIndex:0];
NSArray *array = [dictionary objectForKey:@"data"];
NSMutableArray *emailArray = [NSMutableArray arrayWithArray:array];
[emailArray addObject:[ObjectArrays productWithType:name.text Eemail:email.text Eselected:YES]];
[emailPVC.dataArray removeObjectAtIndex:0];
NSDictionary *firstItemsArrayDict = [NSDictionary dictionaryWithObject:emailArray forKey:@"data"];
[emailPVC.dataArray insertObject:firstItemsArrayDict atIndex:0];
NSLog(@"%d", [emailPVC.dataArray count]);
答案 0 :(得分:0)
在ManualEmail.m中,您在代码中创建了EmailViewController
。但是你永远不会调用任何会调用-viewDidLoad
方法的东西,所以dataArray
永远不会被创建或填写。您需要致电emailPVC.view = <some view you created>;
,才能调用-viewDidLoad
。