views:

206

answers:

2

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

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?
+1  A: 

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!

fbrereto
+1  A: 

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/

JT