我在 UINavigationController 中有一个带有 NSMutableArray 的 rootView Controller 。我需要在未经许可的情况下将数组副本传递给另一个 ViewController。
所以我在一些 ViewController 中执行以下操作:
- (void)setArrExercises:(NSArray *) arrExercs {
// arrExercs NSMutableArray of my custom objects from rootViewController
arrExec = [[NSArray alloc] initWithArray:arrExercs];
}
数组创建好了,但是在TableView的委托(delegate)方法中:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrExec count];
}
没有项目。
最佳答案
也许你必须这样尝试
-(void) setArrExercises:(NSArray *) arrExercs {
// arrExercs NSMutableArray of my custom objects from rootViewController
NSArray* arrExec = [[NSArray alloc]init];
for( int i=0; i<[arrExercs count]; ++i )
[arrExec addObject:arrExec[i]];
}
关于objective-c - 从 UIViewController 传递 NSArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6120866/