Xcode组织文件和文件夹(核心数据模型对象 - iPhone) [英] Xcode organising files and folders (core data model objects - iPhone)

查看:122
本文介绍了Xcode组织文件和文件夹(核心数据模型对象 - iPhone)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPhone开发,并且当使用Core Data时,实体自动生成文件的主要建议是选择* .xcdatamodel文件和创建新文件等。这将创建*。 m和* .h文件。然后将它们移动到Classes目录或Classes的子目录。



但是,当我查看我的github仓库时,我注意到所有以上述方式自动生成的模型文件都存在于项目文件夹的根目录(好像他们是一个资源)。



底层文件结构可能有也可能没有问题(我不确定这一点),但我想让我的存储库更少杂乱。我可以看到熵接管,因为项目变得更大,有更多的文件来应对。



我的问题是:是否有一种方法来组织底层文件结构,而不会弄乱项目设置或github看到的项目?

$ b

解决方案

我希望上面的内容不是不清楚,是的,这是可能的。 Xcode组(黄色的文件夹,如您的资源)完全独立于文件系统 - 它们不直接表示目录。如果选择一个组并转到文件 - >获取信息,您可以选择该组文件的基本路径。您可以通过文件选择器在那里创建和选择一个新的文件夹。



一旦你这样做,该组中的所有文件将变红 - Xcode不能再找到它们通过新的路径。使用Finder(或Git)将它们移动到您的新目录,并且所有都应该很好。



Xcode默认将新的管理对象类放置在模型



作为一个旁注,我强烈推荐Rentzsch的 Mogenerator 来处理托管对象类的创建。它将Xcode的自动生成的代码与您的自定义代码分离,然后在每次模型更改时自动重新生成模板代码(而不会丢失您自己的代码)。


I am developing for the iPhone and the prevailing advice on auto-generating files from entities, when using Core Data, is to select the *.xcdatamodel file and the create the new file(s) etc. This creates the *.m and *.h files in the Resources directory. These are then moved to the Classes directory or a subdirectory of Classes.

However, when viewing my github repository I notice that all of the model files which have been auto-generated in the above mentioned way are present on the root of the project folder (as if they were a resource).

The underlying file structure may or may not matter (I'm unsure on this point) but I would like to make my repository less disorganised. I can see entropy taking over as the project gets much bigger and there are more files to contend with.

My question is therefore: is there a way to organise the underlying file structure without messing up the project settings or the way github sees the project?

I hope the above isn't unclear and I look forward to your replies.

解决方案

Yes, this is possible. The Xcode groups (the yellow "folders," like your Resources) are completely independent of the file system - they don't directly represent directories. If you select a group and go to File -> Get Info, you can select the base path for that group of files. You can create and select a new folder through the file chooser there.

Once you do this, all the files in that group will go red - Xcode can no longer find them through the new path. Use the Finder (or Git) to move them into your new directory, and all should be well.

Xcode defaults to placing new Managed Object classes in the folder that the model is in, so new resources will get placed there automatically.

As a sidenote, I highly recommend Rentzsch's Mogenerator to handle Managed Object class creation. It divorces Xcode's auto-generated code from your custom code, and then automagically regenerates the template code every time your model changes (without losing your own code).

这篇关于Xcode组织文件和文件夹(核心数据模型对象 - iPhone)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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