如何使用核心数据使用ID数组获取对象数组? [英] How to fetch array of objects using array of ids using core data?

查看:78
本文介绍了如何使用核心数据使用ID数组获取对象数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ID数组.我想获取ids数组中各项的核心数据实体.我们如何使用 NSFetchRequest 来实现呢?

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?

推荐答案

使用 NSPredicate

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

设置实际的id属性名称,而不是 itemId .现在,使用此提取请求执行提取

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

这篇关于如何使用核心数据使用ID数组获取对象数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆