Manually call tableview's didSelectRowAtIndexPath?

Discussion in 'iPhone/iPad Programming' started by Danneman101, May 30, 2009.

  1. macrumors 6502

    Joined:
    Aug 14, 2008
    #1
    Is it possible to manually call the tableview's didSelectRowAtIndexPath with, say, the row-nr 1?

    Code:
    - (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:

    Code:
    [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.
     
  2. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #2
    Did you put a prototype in your interface declaration?

    Did you intend to to pass an integer into a indexPath object pointer parameter?
     
  3. thread starter macrumors 6502

    Joined:
    Aug 14, 2008
    #3
    No, I just declared the tableView as such:
    Code:
    @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?


    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?
     

Share This Page