How to fetch array of objects using array of ids using core data?

别说谁变了你拦得住时间么 提交于 2021-01-02 06:25:19

问题


I have an array of ids. I want to fetch core data entity for the items in the ids array. How can we implement that using NSFetchRequest?


回答1:


Use NSPredicate

fetchRequest.predicate = NSPredicate(format: "itemId IN %@", itemIds)

Instead of itemId set your actual id property name. Now perform a fetch with this fetch request




回答2:


let hrData = self.cstProjectDetails as NSArray



来源:https://stackoverflow.com/questions/51264432/how-to-fetch-array-of-objects-using-array-of-ids-using-core-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!