Some says we cannot change the request object. Some says we can change the query. Some says we cannot change the predicate.
How do you change the query if you do not change the predicate?
That’s kind of strange right.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
It’s not an SQL query, it’s fetch. A query is a SQL specific concept while a fetch is a Core Data concept that works with any type of Core Data store.
You can change the
fetchRequestvalue of a NSFetchedResultsController but its somewhat involved. From the docs:It is the cache that causes the problems with modifying the fetch request.
You can also change the predicate of a NSFetchRequest object but if you use that fetch with a fetched results controller, you have to perform the above steps.
The problems comes when the cached objects are not the same set returned by the new fetch request. Often it is simpler and cleaner to just create a new fetch request object or a new fetched results controller object.
You do have to freeze the tableview with
beginUpdatewhile all this is going on otherwise the tableview’s rows and sections will come out of sync with the data causing a crash.