您好我正在尝试为嵌套在 NSMutableArray 内的视图控制器设置属性,例如我在这个数组中有 3 个视图控制器:
FirstViewController *firstViewController = [FirstViewController alloc];
SecondViewController *secondViewController = [SecondViewController alloc];
ThirdViewController *thirdViewController = [ThirdViewController alloc];
NSMutableArray *viewControllerClasses = [[NSMutableArray alloc] initWithObjects:
firstViewController,
secondViewController,
thirdViewController,
nil];
for (int x=0; x<[viewControllerClasses count]; x++) {
// as an example to set managedObjectContext I otherwise would set firstViewController.managedObjectContext = context;
[viewControllerClasses objectAtIndex:x].managedObjectContext = context;
}
但这会导致错误:请求成员“managedObjectContext”不是结构或联合。“firstViewController”不应该与 [viewControllerClasses objectAtIndex:0] 相同吗?