Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8796987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:45:04+00:00 2026-06-13T23:45:04+00:00

I am showing all the records in UITableView easily by using: if (_fetchedResultsController !=

  • 0

I am showing all the records in UITableView easily by using:

if (_fetchedResultsController != nil) {
    return _fetchedResultsController;
}

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
                               entityForName:@"Memo" inManagedObjectContext:[appDelegate managedObjectContext]];
[fetchRequest setEntity:entity];

NSSortDescriptor *sort = [[NSSortDescriptor alloc]
                          initWithKey:@"memodate" ascending:NO];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];

NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                    managedObjectContext:[appDelegate managedObjectContext] sectionNameKeyPath:nil
                                               cacheName:nil];
self.fetchedResultsController = theFetchedResultsController;

return _fetchedResultsController;

And for Searching records I am performing this:

- (void)searchBar:(UISearchBar *)aSearchBar textDidChange:(NSString *)searchText {

if (self.searchBar.text ==nil || [self.searchBar.text isEqualToString:@""])
{
    self.fetchedResultsController=nil;
}
else
{
    NSPredicate *predicate =[NSPredicate predicateWithFormat:@"memodesc CONTAINS[cd] %@", self.searchBar.text];
    [_fetchedResultsController.fetchRequest setPredicate:predicate];

}

NSError *error = nil;
if (![[self fetchedResultsController] performFetch:&error]) {
    // Handle error
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();  // Fail
}

[self.tableView reloadData];}

My Question is what is the right way to search all records if searchText value is nil or ""

I am setting self.fetchedResultsController=nil; again for retrieving all the initial results.

But I don’t think so this is the right way. It should be doable with predicate ?

Update:

Its working finw with this predicate

        NSPredicate *predicate =[NSPredicate predicateWithFormat:@"1=1"];
        [_fetchedResultsController.fetchRequest setPredicate:predicate];

But my app is crashing if I used this:

NSPredicate *predicate =[NSPredicate predicateWithFormat:@"All"];
[_fetchedResultsController.fetchRequest setPredicate:predicate];

Unable to parse the format string "ALL"'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:45:05+00:00Added an answer on June 13, 2026 at 11:45 pm

    Just set the predicate to nil if you want to fetch all entities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Code of Showing all Records to a Message box using string
The following code (without showing it all) is my first attempt at using classes.
I had the below code, but it is showing all records due to the
i created one grid view application, it's working fine now showing all images in
Plupload is showing in all browsers except IE. I can't even see the upload
A customer has asked this morning why he isn't showing up at all in
in all the examples I find of Zend_Form the view showing the form corresponds
Hi All, In my iPhone Application when I run it on device showing these
i have between 1 and 10 floating divs. If i'm showing 1-5 or all
My site has a form which insert records in a database using ajax, at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.