Re: Cocoa patterns?
Re: Cocoa patterns?
- Subject: Re: Cocoa patterns?
- From: Jonathan Hendry <email@hidden>
- Date: Sun, 26 Aug 2001 21:35:00 -0500
On Sunday, August 26, 2001, at 07:09 , brian hook wrote:
This may be a case of necessitating "unlearning" the crap that MFC and
AppWizard on Win32 kind of teach people. I had assumed that since IB
generates files for me that any radical changes done to a UI via IB would
require new source file generation, thus destroying existing source.
I've been also assuming that the MVC paradigm minimizes a lot of this
damage by isolating the damage to the "V" part, which ideally should be
trivial to re-implement since the real work happens in the "M" part.
Does this sound right?
Well, the amount of code IB generates is extremely minimal. It's so
little that, if you change the nib, it's simple to add the line
of code by hand, rather than having IB do it.
Also, many of the things in IB don't require any code to be changed
or generated.
It's not like other environments where dropping a widget on a window
generates all kinds of code to allocate the widget, initialize it,
size it, etc.
IB just generates stub code. I just created a class in IB,
added three outlets and three actions. Then I had it generate
the .h and .m files. Here's what it came up with:
@interface MyObject : NSObject
{
IBOutlet id myOutlet;
IBOutlet id myOutlet1;
IBOutlet id myOutlet2;
}
- (IBAction)myAction:(id)sender;
- (IBAction)myAction1:(id)sender;
- (IBAction)myAction2:(id)sender;
@end
@implementation MyObject
- (IBAction)myAction:(id)sender
{
}
- (IBAction)myAction1:(id)sender
{
}
- (IBAction)myAction2:(id)sender
{
}
@end
That's about all the code that IB generates.
If you go back to add an outlet or an action method,
IB will (in 10.0.4) overwrite any existing files with
something like the code above. But, as you can see,
it's not really a lot of code for you to write by hand.
If you're still concerned, you could just adopt a policy
of never using IB's Create Files command, and create the files in PB.