PDA

View Full Version : Manually call tableview's didSelectRowAtIndexPath?




Danneman101
May 30, 2009, 08:14 PM
Is it possible to manually call the tableview's didSelectRowAtIndexPath with, say, the row-nr 1?


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// stuff
}


If so, how would you construct that call? Im a bit confused as to how to make a functioncall with parameters in obj-c. My guess would be:


[MyTableView didSelectRowAtIndexPath:1];


..since my viewcontroller both declares and sets to property "MyTableView" in .h, and synthezises it in .m.

But even though it compiles (with a warning that "UITableView may not respond to -"didSelectRowAtIndexPath"), it crashes pretty quickly.



firewood
May 30, 2009, 09:15 PM
Did you put a prototype in your interface declaration?

Did you intend to to pass an integer into a indexPath object pointer parameter?

Danneman101
May 31, 2009, 05:50 AM
Did you put a prototype in your interface declaration?

No, I just declared the tableView as such:

@interface Level1ViewController : UIViewController <UINavigationBarDelegate, UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *myTableView;
}


The actual function-definition (didSel..) is in the .m-file. Do I need to put its prototype in the .h-file as well?


Did you intend to to pass an integer into a indexPath object pointer parameter?

Well, what I want to do is that under a certain condition managed by a settings-variable (for instance, if "setting_row == 1"), I want a table-row to be automatically selected as if row 1 in the tablerow had been pressed which would have called didSelectRowAtIndexPath. So that would mean manually passing the row-nr as a parameter, but perhaps it should not be in the form of an integer?