I'm using NSPersistentContainer to access my core data in iOS10 app and Xcode 8. Similar to Entity, I added a "UserFetchRequest" in my Coredata xcdatamodel. Below is the screen shot.
How can I access the "UserFetchRequest" in the code?
I'm using NSPersistentContainer to access my core data in iOS10 app and Xcode 8. Similar to Entity, I added a "UserFetchRequest" in my Coredata xcdatamodel. Below is the screen shot.
How can I access the "UserFetchRequest" in the code?
Having given your fetch request a name in the Data Model Inspector on the right hand side:
(in my case named "randomFetch" where yours is "UserFetchRequest"), get the model from the persistentContainer:
and then access the fetch request using the
fetchRequestTemplate(forName:)
method:You can then execute this fetch request as normal.