核心数据可变的NSArray的ID [英] Core Data Transformable NSArray of IDs

查看:164
本文介绍了核心数据可变的NSArray的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CoreData实体类X,它存储一个NSString ID的NSArray,在一个可变属性(让我们说someIDs)...



NSString ID,如何在其someID属性中查找(使用谓词)所有包含ID的实体X?

注意:我知道

解决方案

你不能。一个transformable属性存储为SQLite存储文件中的数据blob(使用 NSCoding 方法)。核心数据获取请求(转换为SQLite查询)
无法访问可转换属性的内容。



如果您不想要使用一对多关系,那么您只能抓取所有对象并过滤抓取的 NSArray


I have an CoreData entity class X, which stores an NSArray of NSString IDs, inside a transformable attribute (lets say someIDs)...

Given an NSString ID, how can i find (using Predicate) all entities X, which contains the ID, in their someIDs attribute?

Note: i know about relationships (so no need to propose using a relationship) etc. but what to do in this case?

解决方案

You can't. A transformable attribute is store as a data blob in the SQLite store file (using NSCoding methods). The Core Data fetch request (which is translated to a SQLite query) has no access to the contents of the transformable attribute.

If you don't want to use a to-many relationship then you can only fetch all objects and filter the fetched NSArray.

这篇关于核心数据可变的NSArray的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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