开发者

what is the bestpractice to find the index of a mutablearray send to a sort tableview?

开发者 https://www.devze.com 2023-04-05 13:00 出处:网络
Sorry for that question, but what is the best practice to to find the index of a mutablearray send to a sort tableview ?

Sorry for that question, but what is the best practice to to find the index of a mutablearray send to a sort tableview ? 1. i create a nsmutablearray with a dictionnary 2. i create a table view with sort my array 3. when i clik on the table v开发者_如何学运维iew, how to find the index of the origin array to modify it ?


Set up the UITableViewDelegate (usually your view controller), and implement the method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    //the index of your mutable array can be found with:
    NSUInteger *myArrayIndex = indexPath.row;
}

If your view controller is a UIViewController subclass, and not already set up as the tableview delegate, do so by declaring it in your view controller's .h file

@interface MyViewController : UITableViewController <UITableViewDelegate> {...

If you view controller is a UITableViewController, then it already conforms to this protocol.

0

精彩评论

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