Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Variables are unavailable once you reach the end of scope (I don't know if they're nil or released, I just know you can't use them). </p> <p>What you want to do is A) save that value to persistent storage <em>or</em> B) make a persistent variable.</p> <p>A) <em>Set the object to storage (In this case NSUserDefaults, because it's dead easy:</em></p> <pre><code>NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; prefs = [setObject:checkedData forKey:@"checkedData"];</code></pre> <p><em>Then, to check the object the way you wanted to, you could do this:</em></p> <pre><code>NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; <b>if([[prefs objectForKey:@"checkedData"] compare: indexPath]== NSOrderedSame)</b>{<br>cell.AccessoryType = UITableViewCellAccessoryCheckMark;<br>}</code></pre> <p>B) Save the object as a persistent variable:</p> <p><em>In your .h:</em></p> <pre><code>@interface ... : ...{ } @property(nonatomic, retain) NSIndexPath *checkedData; @end</code></pre> <p><em>In the .m:</em></p> <pre><code>@implementation @synthesize checkedData; @end</code></pre> <p>Now, to set this variable:</p> <pre><code>self.checkedData = indexPath;</code></pre> <p><em>To check it:</em></p> <pre><code><b>if([self.checkedData compare:indexPath] == NSOrderedSame)</b>{<br>cell.accessoryType = UITableViewCellAccessoryTypeCheckMark;<br>}</code></pre> <p>There really isn't going to be a whole lot of difference, it's up to you to decide what you want. If you use NSUserDefaults though, keep in mind that the data persists across launches. If you don't want that, but you want to use it you have to empty the object when you close the app: <code>[prefs removeObjectForKey:@"checkedData"];</code></p> <p>Happy coding, </p> <p>Zane</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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