简体   繁体   中英

How to populate the rootviewcontroller tableview with an NSMutableArray

I am trying to populate the tableview with an NSMutableArray, and I am having a really hard time with it.

This should be simple I'm thinking, but I can't get it to work.

Any help would be appreciated.

Thanks

You simply have to create an object implementing the UITableViewDataSource.

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

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    /* create your cell here */

    AnObjectFromYourArray *myObject = [self.yourArray objectAtIndex:[indexPath row];

    /* fill the cell with the info in my object */

    return yourCell;
}

simple as that.

Greg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM