核心数据列表实体名称 [英] Core Data List Entity Names

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

问题描述

使用Core Data,我如何列出(即返回NSStrings的NSArray)我模型中的所有实体类型?

using Core Data, how would I list (i.e. return an NSArray of NSStrings) all the entity types that I have in my model?

,例如Customer,Invoice等等...

such as Customer, Invoice, etc...

推荐答案

您可以从模型的实体描述中获取名称:

You can get the names from the model's entity descriptions:

NSArray *entityNames = [[myManagedObjectModel entities] valueForKey:@"name"];

或者只是:

NSArray *entityNames = myManagedObjectModel.entities.name;

这篇关于核心数据列表实体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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