Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To create this structure is quite simple, you create a dictionary that has an array value for your key `Cards'. Example below..</p> <pre><code>NSMutableDictionary *cards = [NSMutableDictionary dictionary]; NSMutableArray *cardArray = [NSMutableArray array]; NSMutableDictionary *item = [NSMutableDictionary dictionary]; [item setValue:@"Card Name" forKey:@"Name"]; [item setValue:@"Card Number" forKey:@"Number"]; [item setValue:@"Card Type" forKey:@"Type"]; [cardArray addObject:item]; [cards setValue:cardArray forKey:@"Cards"]; [[NSUserDefaults standardUserDefaults] setValue:cards forKey:@"user_cards"]; [[NSUserDefaults standardUserDefaults] synchronize]; </code></pre> <p>In order to retrieve your cards, you would do something like..Assuming self.cards is an NSMutableArray ivar..</p> <pre><code>NSMutableDictionary *stored = [[NSUserDefaults standardUserDefaults] valueForKey:@"user_cards"]; self.cards = [stored valueForKey:@"Cards"]; </code></pre> <p>Your tableview should use <code>cards</code> ivar to populate your data, like below.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath ...... //Now we populate each row of the cell with each `card` Name. cell.textLabel.text = [[self.cards objectAtIndex:[indexPath row]] valueForKey:@"Name"]; ..... } </code></pre> <p>To resave any newly added cards to your stored dictionary you would do something like this..</p> <pre><code>NSMutableDictionary *newCard = [NSMutableDictionary dictionary]; [newCard setValue:@"Card Name" forKey:@"Name"]; [newCard setValue:@"Card Number" forKey:@"Number"]; [newCard setValue:@"Card Type" forKey:@"Type"]; [self.cards addObject:newCard]; [[NSUserDefaults standardUserDefaults] valueForKey:@"user_cards"] setValue:self.cards forKey:@"Cards"]; [[NSUserDefaults standardUserDefaults] synchronize]; </code></pre> <p>If this has helped with your questions, please accept it as an answer.</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.
    3. 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