Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Initialize NSUserDefaults with the [NSUserDefaults standardUserDefaults] method.
Then, in the cellForItemAtIndexPath method, after initializing the cell, you take the object you want from your NSUserDefaults.
Hope I could help.
For example:
@interface MyViewController ()
@property (nonatomic, weak) IBOutlet tableView *tableView;
@property (nonatomic, strong) NSUserDefaults *userDefaults;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"cell";
MyTableViewCell *cell = [tableView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
cell.myProperty = [self.userDefaults objectForKey:@"myObject"];
return cell;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question