How to test which UITableView is being passed

Discussion in 'iOS Programming' started by JefRH1, Aug 17, 2008.

  1. JefRH1 macrumors newbie

    Joined:
    Aug 17, 2008
    #1
    - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    I have two UITableView's on the same screen. Both go through the routine above. How can I use 'tv' and test which one is currently being passed?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Assuming you have kept references to the two table views in instance variables simply check if they are the same:

    Code:
    @interface MyClass
    {
    UITableView *tableView1;
    UITableView *tableView2;
    }
    @end
    
    @implementation MyClass
    
    // Assume that tableView1 and tableView2 are either programatically setup or are IBOutlets and linked in interface builder
    
    - (UITableViewCell *)tableViewUITableView *)tv cellForRowAtIndexPathNSIndexPath *)indexPath {
    if (tv==tableView1)
    {
    // Do table view 1 here
    }
    }
    @end
    
     
  3. JefRH1 thread starter macrumors newbie

    Joined:
    Aug 17, 2008
    #3
    oooooook

    Wow I think I need some sleep. That was to easy.

    Thanks for the prompt reply
     

Share This Page