In my app, I have a search bar above my table view. My problem is this:
If I go into my table view and add an item to any level of the hierarchy, and then go back to the root (where the search bar is) and try to search for it, it doesn't show up in the results it.
For example, if I already have itemOne and itemTwo in core data when the app is launched, I can search and find them just fine. But if I add itemThree and try to search for it, it is not found.
The array that my search bar uses to load all of the items from Core Data into is located in the viewDidLoad method:
- (void)viewDidLoad
{
listOfItems = [[NSMutableArray alloc] init];
NSMutableArray* allItemArray = [CoreDataHelper searchObjectsInContext:@"Item" :entitySearchPredicate :@"Description" :YES :managedObjectContext];
NSDictionary *allItemDict = [NSDictionary dictionaryWithObject:allItemArray forKey:@"Items"];
[listOfItems addObject:allItemDict];
}
I know that the viewDidLoad isn't running after I add the last item, and that is my problem. But I don't know where to put this code that it will update with any items that have been added.
Any input is appreciated. Thanks.
Do the same things on viewWillAppear ..things will be right.