Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unset NSFetchRequest's fetchLimit?

The documentation for Cocoa's NSFetchRequest fetchLimit property says:

The fetch limit specifies the maximum number of objects that a request should return when executed.

If you set a fetch limit, the framework makes a best effort to improve efficiency, but does not guarantee it.

However, it doesn't tell you how to unlimit the maximum number of objects that a request should return if the fetch limit has already been set.

How can I return an unlimited number of matching objects after the previously limiting the number of objects with fetchLimit on my NSFetchRequest?

like image 852
Josh Sherick Avatar asked Sep 06 '25 02:09

Josh Sherick


1 Answers

From some quick testing, the default value for fetchLimit when an NSFetchRequest is instantiated is 0, and setting the value to something other than 0 and then back to 0 will not limit the results returned.

So, as of Swift 4, set fetchLimit to 0 to return unlimited results.

like image 141
Josh Sherick Avatar answered Sep 07 '25 20:09

Josh Sherick