views:

288

answers:

5

I started using groups in Xcode the same way I use packages in Java or namespaces in C++, even though groups have no effect on the language.

Then I discovered Smart Groups and realised that it's sort of pointless to have my code neatly organised in "folders".

Do you use groups? If so, how and why?

+9  A: 

Groups are just an organisational tool, and you can use them in the way that is most logical to you.

Often developers will put their Model, View and Controller classes in separate groups. You might also want to put header files in their own group to reduce clutter.

I create a group for "utility" classes like categories, and a group for each main component of the application, for instance "Inspector" or "Preview". In those groups, the classes are further organised into Model, View and Controller groups.

It's up to you though, just do whatever feels natural.

Rob Keniger
There are already smartgroups for header and implementation files.
Abizern
as an aside for groups... they are 90% just organizational. but i bleieve there is an option for xcode to create the directory structure too when you drag files in.
pxl
+1  A: 

If you're using unit tests, these can go in their own group as well.

Abizern
A: 

As mentioned by others, I use groups for Model/View/Controller and for unit testing.

I use groups also for Doxygen documentation (doxyfile configuration file and .dot pictures) and for embedded applications such as ffmpeg source code.

mouviciel
A: 

I group my files to keep things organized and I also have two main trees, one with header files, and one with implementation files. Mainly because I'm fastidious on keeping things organized and clean, and I have a strong Java background, and want everything in a package format. I find that keeping header files separate from implementation files makes it quicker to find something if you are navigating the group tree. So I really have two trees.

If I know what file I want to look at I always use (command)+(Shift)+(D) to open the file quickly by name. If I can't remember the name of the file I navigate the group tree. You can also quickly jump between the impl and header file with a shortcut, and I use that often. This way it doesn't matter if you're navigating the header or impl tree.

I'm not at a mac right now to check but I think the sequence is (ctrl)+(alt)+(upArrow), or maybe (alt)+(command)+(upArrow).

Matthieu Cormier
If you're on Snow Leopard -> three finger swipe up will switch between implementation and header file.
Abizern
I think you also need the new Macs. Mine's an all aluminium model and that doesn't seem to work.
Rui Pacheco
I think it's only the newer macs that have multi-touch support. But the tip works with those.
Abizern
"as Brent Simmons says, “Every time you touch the mouse, God kills a kitten.”" I assume this philosophy applies to touch pads too.Reference -- http://www.red-sweater.com/blog/331/brent-simmons-on-large-cocoa-projects
Matthieu Cormier
A: 

In the Info window for a group, you can set the group to correspond to a real folder on disk. Then, when you create files in your project by right-clicking on the group and choosing “Add New File”, Xcode will create the files in the group's folder.

I do this for my test case classes. You can do it for any set of classes you want to keep both in their own group and in their own folder.

Peter Hosey