嗨,我有一个分组的表格视图,第一部分包含电子邮件列表,第二部分只有两行,手动添加电子邮件并从联系人中选择电子邮件。
ManualEmail.m 中的日志一直为计数记录 0,并且 EmailViewController 中的数组从未修改过,但我不知道出了什么问题
这是我目前的设置
电子邮件视图控制器.h
@property (nonatomic, retain) IBOutlet NSMutableArray *dataArray;
电子邮件视图控制器.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];
}
手动电子邮件.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]);