i'm using alecrim coredata in 1 of project. setup ok have 1 problem when configure fetchedresultcontroller
tableview
have done
fileprivate private(set) lazy var fetchedresultscontroller: fetchrequestcontroller<movie> = { let query = self.persistentcontainer!.viewcontext.movies.orderby(ascending: false, { $0.releasedate }) return query.tofetchrequestcontroller() }()
my question how can customize fetchrequestcontroller? example change fetchbathsize
, fetchlimit
, fetchoffset
...?
anyhelp appreciate. thanks
try this
lazy var fetchedresultscontroller: nsfetchedresultscontroller<nsfetchrequestresult> = { // initialize fetch request let fetchrequest = nsfetchrequest<nsfetchrequestresult>(entityname: "item") // add sort descriptors let sortdescriptor = nssortdescriptor(key: "age", ascending: true) fetchrequest.sortdescriptors = [sortdescriptor] // initialize fetched results controller let fetchedresultscontroller = nsfetchedresultscontroller(fetchrequest: fetchrequest, managedobjectcontext: (uiapplication.shared.delegate as! appdelegate).manageobjectcontext, sectionnamekeypath: nil, cachename: nil) // configure fetched results controller fetchedresultscontroller.delegate = self return fetchedresultscontroller }()
Comments
Post a Comment