Re: Two view controllers in one set of files (Noob question)
Re: Two view controllers in one set of files (Noob question)
- Subject: Re: Two view controllers in one set of files (Noob question)
- From: "I. Savant" <email@hidden>
- Date: Wed, 25 Mar 2009 12:57:25 -0400
On Wed, Mar 25, 2009 at 12:31 PM, Weydson Lima <email@hidden> wrote:
> I want to set up two view controllers but I don't want to create a XIB and
> .m/.h for each controller. Is it possible to use a single set of files to do
> so? As I was reading the book by Mark and LaMarche, it looks that their
> approach is to create a pair of those files for each View Controller.
It's not entirely clear what you want to do because the two things
you mentioned (separate/same XIB file versus separate/same source code
file) aren't directly related.
You can certainly have more than one class declared and implemented
in the same .h/.m files. You can also have multiple controllers within
the same XIB. Wherever your classes are declared/implemented, they
show up as "available" in Interface Builder as individual classes, so
when you instantiate them, they appear as if they were
declared/implemented in different files. IB does not care.
May I ask why you don't want separate source code files for separate
classes? If they're all heavily related (such as NSTabView /
NSTabViewItem), it makes some sense, but if they're separate
controllers, you're just cluttering your files. It's far easier when
you have one class (or one small group of two or three related
classes) in one file because you can easily find them in your source
tree. Combining lots of source from multiple medium-to-large classes
in a single file will undoubtedly make navigating your code harder,
and will probably slow down the editor. It's easier in this case just
to separate your classes into their own files.
Incidentally, I avoid combining multiple classes into single files
whenever possible. In a current (complicated scientific data mining
application) project, there's only one time I've done this and the
"mini class" functions as a temporary "sabot" for translating /
arranging the values of a complicated multidimensional data set that's
only used by the computational engine. My obsessive-compulsive nature
still causes me to obsess over whether it should be in its own file
... :-)
--
I.S.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden