iphone - NSFetchedResultsController refresh refetch? -
Text after "
Repeat the data from my NSFetchedResultsController using a different predicate that is set using a Boolean value Want to do ? I have NSFetchedResultsController to bring a new set of fresh data.
- (zero) refreshFetchedResultsController {NSLog (@ "refreshFetchedResultsController"); NSError * Error = Zero; If: {ErrorType Loading "@" Error loading data "@" [UIAlertView alloc] initWithTitle ([[self fetchedResultsController] performFetch & amp; error]!): NSLocalizedString (), message: [ NSString stringWithFormat: NSLocalizedString (@ "This error was:% @, quitting.", @ "This error was:.% @, Leaving"), [error localizedDescription]] Rep: AutoCodeButtonTitle: NSLocalizedString (@ "Cancel" @ "Cancel") otherButtonTitles: Zero]; [Alerts show]; }
}
who says
- (NSFetchedResultsController *) fetchedResultsController {if (! _fetchedResultsController = zero) {NSLog ( @ "I was killed."); Return _fetted result controller; } NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] init]; TapAppDelegate * appDelegate = (TapAppDelegate *) [[UIApplication shared epiceling] representative]; NSManagedObjectContext * Managed ObjectContax = App Delegate.managedObjectContext; NSEntityDescription * entity = [NSEntityDescription EntityForName: @ Managed Object Contact in "Favorites": Managed Object Contains]]; NSString * sectionKey = @ "favname"; NSSortDescriptor * sortDescriptor = [[NSSortDescriptor alloc] initWithKey: @ "favname" ascending: Yes]; NSArray * sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, zero]; If (showAll == no) {if (isXSelected == no) {NSPredicate * predicate = [NSPredicate predicateWithFormat: @ "isFirst == TRUE"]; [FetchRequest set candidate: count]; } If (isXSelected == Yes) {NSPredicate * predicate = [NSPredicate predicateWithFormat: @ "isFirst == FALSE"]; [FetchRequest set candidate: count]; }} [FetchRequest SetSortScriptor: Sort descriptor]; [FetchRequest Set Entity: Entity]; [FetchRequest set FetchBatchSize: 20]; NSFetchedResultsController * frc = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest Managed Object Contains: Managed ObjectContact sectionnamePath: section's cache name: zero]; [Sortedipitre release]; [Sort descriptor release]; Frc.delegate = self; _fetchedResultsController = frc; [FetchRequest release]; Return _fetted result controller; }
Here's how we do this in an application:
// Assume that it exists NSPredicate * predicate; NSString * cacheName; [[FetchedResultsController fetchRequest] Setup: Speak]; [NSFetchedResultsController deleteCacheWithName: cacheName]; NSError * Error = Zero; [FetchedResultsController Display Fetch: & amp; Error]; If (error) {// report error}
Comments
Post a Comment