2011-05-25 74 views
1

我在UINavigationController中使用NSMutableArray创建了一个rootView控制器。我需要将数组副本传递给另一个ViewController,而无需更改许可证。从UIViewController传入NSArray

所以,我中一些的ViewController以下内容:创建

- (void)setArrExercises:(NSArray *) arrExercs { 
    // arrExercs NSMutableArray of my custom objects from rootViewController 
    arrExec = [[NSArray alloc] initWithArray:arrExercs]; 
} 

阵列,但在TableView中的委托方法:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [arrExec count]; 
} 

即使世界是没有任何项目。

回答

1

也许你必须尝试以这种方式

-(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]]; 
    }