Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess I don't understand what you are asking. indexPath is the IndexPath of the row you just created. You set a property to this value, but that property will only contain the IndexPath of the LAST row created.</p> <p>Updated to show examples:</p> <p>Method 1 - You aren't call the other method from within cellForRowAtIndexPath. In this case, you will need a private property of type NSIndexPath (only included code for MyViewController import and @interface declaration to show you where to put the private property declaration:</p> <p>in your .m file:</p> <pre><code>#import "MyViewController.h" @interface MyViewController () @property(nonatomic,strong) NSIndexPath *lastIndexPathCreated; @end @implementation MyViewController @synthesize lastIndexPathCreated; </code></pre> <p>...</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // All your other cell setup code self.lastIndexPathCreated = indexPath; return cell; } -(void)someOtherMethod { // The last IndexPath of the row LAST created is self.lastIndexPathCreated } </code></pre> <p>Method 2: This assumes you call some other method from within cellForRowAtIndexPath:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // All your other cell setup code [self myOtherMethodWithIndexPath:indexPath]; return cell; } -(void)myOtherMethodWithIndexPath:(NSIndexPath *)lastIndexPath { // Do something with lastIndexPath } </code></pre> <p>Hope this helps</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.
    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