Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 792
Sheik_101 Avatar asked Jul 10 '18 11:07

Sheik_101


1 Answers

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

like image 110
Andrey Chernukha Avatar answered Oct 16 '22 00:10

Andrey Chernukha