如何获取核心数据中现有实体(表)的列表 [英] How to get list of existing entities(tables) in core data

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

问题描述

如何获取核心数据中特定模式(托管对象模型)的现有实体(表)列表。我刚刚开始实现核心数据概念,坚持这些要点,请帮助

How to get list of existing entities(tables) for a particular schema(Managed object model) in core data. I just started implementing core data concept and stuck with these points, please help

像:SELECT COUNT(*)FROM information_schema.tables WHERE table_schema ='dbName';

something like : SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = 'dbName';

感谢

推荐答案

您应该通读 Apple的核心数据编程指南。要获得特定 NSManagedObjectModel 的实体,您可以使用下列其中一个(假设您有一个 NSManagedObjectModel 命名 objectModel ):

You should read through Apple's Core Data Programming Guide. To get the entities for a particular NSManagedObjectModel, you would use one of the following (this assumes you have an NSManagedObjectModel named objectModel):

NSArray *myEntities = [objectModel entities];
// Array of all entities in the model

NSDictionary *myEntities = [objectModel entitiesByName];
// Dictionary of entities in the model, with the entity names as keys

请阅读 NSManagedObjectModel类参考

看起来你是从SQL背景来的(像我一样)。 Core Data中有许多不同的概念 - 有时候,一旦理解它们,有时需要比可能使用的简单SQL语句更多的工作。我认为重要的是,没有SQL行李来处理核心数据,如果你是第一次学习如何使用数据库,这将有助于避免挫折。

It appears you're coming from a SQL background (as I was). There are a number of concepts in Core Data that are different - sometimes for the better, once you understand them, sometimes requiring more work than a simple SQL statement you may be used to. I think it's important to approach Core Data without SQL "baggage" and treat it as if you're learning how to use a database for the first time - this will help avoid frustration.

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

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