管理文件的技术方式——xcode中的文件分组

发布于 2024-08-11 06:21:20 字数 562 浏览 4 评论 0原文

我从过去 3 个月就开始从事 iPhone 开发工作。

通常,在插入视图控制器时,我只需右键单击“类和控制器”即可。添加新组。

&在该组中,我只需添加新视图控制器的 .h、.m 和 . .xib 文件。

在我提问之前,让我们看看我在我的项目中做了什么。

替代文本 http://img230.imageshack.us/img230/4191/picture4kz.png< /a>

我的问题是这样的

  • 这是正确的方式吗?正确的方法是什么?
  • 我们应该将所有 .xib 文件放在资源组下吗?
  • (如果第二个问题的答案是肯定的)为什么我们必须将.xib文件放在资源下?
  • 当我们有太多 .h、.m 和 .m 时,确切的分组方式是什么?项目中的.xib 文件?
  • 当我们创建组时,为什么xcode实际上不创建目录?

I am in iPhone development since last 3 months.

Usually, While inserting a view Controller, I just right click on Classes & add new group.

& Within that group I just add my new view controller's .h, .m & .xib file.

Before my question, let's see what I have done in my project.

alt text http://img230.imageshack.us/img230/4191/picture4kz.png

My questions are something like this

  • Is it in proper way? What is the proper way?
  • Should we put all .xib files under resources group?
  • (If 2nd question's answer is yes) Why we have to place .xib file under resources?
  • What is the exact way of grouping, when we have too many .h, .m & .xib files in project?
  • When we create group, why xcode don't creat a directory in actual?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日落 2024-08-18 06:21:20

Adrian Kosmaczewski 解释了经验丰富的 Xcode 开发人员所熟知的一种方法。这是我使用的方法,它“为所有东西找到一个地方,并将所有东西放在它的位置上”。希望您能找到您想要的文章(链接如下)。此外,他的博客是最好的博客之一。

http://kosmaczewski.net/2009/07/28 /xcode-projects 中的代码组织/

Adrian Kosmaczewski explains an approach known to experienced Xcode developers. It's the method I use and it "makes a place for everything and puts everything in its' place". Hope you find the article, linked below, what you're looking for. Moreover, his blog is one of the best around.

http://kosmaczewski.net/2009/07/28/code-organization-in-xcode-projects/

丢了幸福的猪 2024-08-18 06:21:20

按顺序回答您的问题:

  • 这里的“正确”方法取决于个人喜好,尽管有些方法比其他方法更容易维护和导航。因此,确实不存在包罗万象的“正确”方法。
  • 再次强调,这是个人喜好问题。我专业从事的所有项目都有一些基于文件类型的基本组织。因此,在给定的项目中,您将拥有一个用于资源的目录,一个用于标头的目录,一个用于源的目录等。.xib
  • 文件“不必”位于磁盘上本地的任何位置,甚至位于 XCode 项目中的任何特殊目录下。 XCode 构建系统将通过扩展名将 .xib 文件识别为资源,对其进行编译,并将结果放在正确的位置。 (请注意,这假设该文件列在您的目标“构建资源”步骤下。
  • 如果您发现自己有许多源文件、头文件和资源文件,我建议将它们全部收集到按类型组织的三个单独的文件夹中。 文件名称建立的(例如,AskPassword.h 与 AskPassword.m 相关,与 AskPassword.xib 相关)

然后,文件夹之间是通过 !

To answer your items in order:

  • The "proper" way here depends on personal preference, though there are methods that can be easier to maintain and navigate than others. Therefore there really is no all-encompassing "proper" way.
  • Again, this is a matter of personal preference. All of the projects I have worked on professionally have had some fundamental organization based on the type of file. Thus in a given project you would have one directory for resources, one for headers, one for sources, etc.
  • .xib files don't "have" to be anywhere locally on the disk or even located under any special directory in the XCode project. The XCode build system will recognize the .xib file as a resource by its extension, compile it, and put the result in the proper location. (Note that this assumes the file is listed under your targets "Build resources" step.
  • If you find yourself with many source, header, and resource files, I would recommend gathering them all together into three separate folders organized by type. The relationship, then, between the folders is established by the names of the files (e.g., AskPassword.h is related to AskPassword.m is related to AskPassword.xib).
  • For the answer to this question you would have to ask Apple.

I hope that helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文