开发者

Pass NSArray from UIViewController

I have a rootView controller in the UINavigationController with the NSMutableArray. I need to pass the array copy to another ViewController without a permit to change.

So I do the following in the some ViewController:

- (void)setArrExercises:(NSArray *) ar开发者_如何转开发rExercs {
     // arrExercs NSMutableArray of my custom objects from rootViewController
     arrExec = [[NSArray alloc] initWithArray:arrExercs];
}

Array is created, but in the TableView delegate method:

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

Theres is no items.


Maybe you must try in this way

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜