tags:

views:

95

answers:

1

When a view will disappear I would like to collect the values of some of the switches in my table view, I have pointers to the index path, cell, and control how do I get a pointer to the table view so I can properly point the cell pointer... if I'm thinking correctly I should be able to then get the value of the control pretty quickly throught these pointers... unless somebody has a better idea. If I'm thinking incorrectly I would still like to know how to point to a specific tableView.

Thanks,

Thanks for the answer, it is a regular view, so I made a property of UITableView, and then I used the interface builder to connect thisTableView property to the actual tableView.

If there's a better way let me know. Thanks,

A: 

Wjy don't you have a pointer to your UITableView? Assuming you are using a UITableViewController the class provides one for you (self.tableView). If not you probably should just add a property in your UIViewContoller sublcass for the tableview and put it there.

The table view is, after all, one of the large objects that view controller is controlling and it lives across multiple method calls. Representing your relationship to it with a retained property asserts ownership, just make sure to release it in dealloc and in viewDudUnload if it came from a nib.

Having said that, currently you can generally find a UITableView from a UITableViewCell by asking the UITableViewCell for it superView. This is a bad idea since there is no guarantee there won't be some intermediary cells in the future, since hierarchy of cells you did not layout yourself is an internal implementation detail (a lot of apps broke on 3.0 because they walked around inside Apple's view hierarchies and something changed).

Louis Gerbarg