Search code examples
ioscore-datansfetchedresultscontrollernsfetchrequest

Modify NSFetchedResultsController fetchRequest in iOS 7


I found this answer : https://stackoverflow.com/a/4861732/1486928

I'm trying to do that but it won't let me assign a newly created NSFetchRequest and in the documentation it says :

@property (nonatomic, readonly) NSFetchRequest *fetchRequest

But in the next line it says :

Special Considerations : If you want to modify the fetch request, you must follow the steps described in “The Fetch Request.”

So which is it, am I allowed to modify it or not :/ ? Very confusing that the property is readonly and they say we can modify it :(


Solution

  • The fetchRequest is a read-only property

    open var fetchRequest: NSFetchRequest<ResultType> { get }
    

    But the NSFetchRequest instance is a mutable property so you can change its entity / sort descriptor / predicate / ...