Note that there are some explanatory texts on larger screens.

plurals
  1. POLimit results of NSFetchedResultsController in UITableView
    primarykey
    data
    text
    <p>This will probably seem silly, but I cannot figure out how too set the limit of a NSFetchedResultsController. Even when setting the fetchLimit I still get all records. I want to set the limit to 1 so that in "freemium" mode there is only one option, but when the app is unlocked you get the full table</p> <pre class="lang-objective-c prettyprint-override"><code>NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Poem"]; fetchRequest.returnsObjectsAsFaults = NO; fetchRequest.resultType = NSManagedObjectResultType; fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"createdAt" ascending:NO selector:nil]]; fetchRequest.fetchLimit = 1; // setup my predicate _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:kDataContext sectionNameKeyPath:nil cacheName:nil]; _fetchedResultsController.delegate = self; </code></pre> <p>I also have a method to fetch data. This method is intended to be run at load and when the user unlocks the full version of the app.</p> <pre class="lang-objective-c prettyprint-override"><code>- (void)refetchData { NSError *error = nil; [_fetchedResultsController performFetch:&amp;error]; // handle error [self.documentsTable reloadData]; } </code></pre> <p>I've experimented with setting the UITableView numberOfRowsInSection to return 1, but then I get warning logs. Plus, I feel that is cheating. I'd like to keep the app data-driven.</p> <p>edit: I might also add that I'm using AFIncrementalStore to sync my data with a web service. I'm not sure if this would cause any problems.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload