Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C: How to declare/define method used on tableView
    primarykey
    data
    text
    <p>My initial problem of multiple line selection in a <code>UITableView</code> has been answered in <a href="https://stackoverflow.com/questions/6057819/didselectrowatindexpath-selecting-more-than-one-row-at-a-time">this</a> question. But the answer left me at a point where I can't go on on my own, as I am very new to Objective C and iOS development.</p> <p>Following <a href="https://stackoverflow.com/users/760958/daxnitro">daxnitro</a>s answer, I want to implement the code he/she suggested:</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if ([tableView indexPathIsSelected:indexPath]) { [tableView removeIndexPathFromSelection:indexPath]; } else { [tableView addIndexPathToSelection:indexPath]; } // Update the cell's appearance somewhere here [tableView deselectRowAtIndexPath:indexPath animated:NO]; } </code></pre> <p>I still need the methods and I thought I can do it for <code>indexPathIsSelected</code> (for example) like this:</p> <pre><code>@interface MyTableViewController () - (BOOL)indexPathIsSelected:(NSIndexPath *)indexPath; @end @implementation MyTableViewController // ... - (BOOL)indexPathIsSelected:(NSIndexPath *)indexPath { BOOL bIsSelected = NO; // ... return bIsSelected; } @end </code></pre> <p>But that doesn't work. The error message is: <em>No visible @interface for 'UITableView' declares the selector 'indexPathIsSelected:'</em> Note: The same happens, if I declare the method in the .h file's interface instead.</p> <p>Now, what baffles me, is this: <code>[tableView indexPathIsSelected:indexPath]</code> is somehow called on the <code>tableView</code> object and I don't even know why. Is that something I have to take into account in my method declaration/definition? I feel really stupid right now, that I can't even write a method by seeing its invocation.</p> <p>How do I define and declare the method <code>indexPathIsSelected</code> correctly, so I can use it properly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload