views:

92

answers:

1

I have a favorites plist file when I try to load it like this

- (void)viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];
NSString *path = [[NSBundle mainBundle] pathForResource:@"favorites" ofType:@"plist"];

NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:path];

self.allFavorites = array;
[array release];

}

nothing shows up in the tableView I've implemented

on the contrary when i cut & paste the same code in

-viewDidLoad:

method everything works fine....?

I need to put the code in viewWillAppear because user may add stuff to favorites to keep the favorites list updated. & yes viewWillAppear do gets invoked, in the debug I've realized allFavorites array is empty in the viewWillAppear method...?

What can possibly be the problem....?

I've define allFavorites as follows

NSMutableArray *allFavorites;

then

@property (nonatomic, retain) NSMutableArray *allFavorites;

then

@synthesize allFavorites;
+3  A: 

When you update the backing store, call reloadData on the table view. It caches the data, so it doesn't have any clue that it's changed.

Jason Coco