Re: IBOutlet to same control in different nibs
Re: IBOutlet to same control in different nibs
- Subject: Re: IBOutlet to same control in different nibs
- From: "Michael Ash" <email@hidden>
- Date: Fri, 18 Jul 2008 00:32:33 -0400
On Thu, Jul 17, 2008 at 7:52 PM, Ken Thomases <email@hidden> wrote:
>> How can I build one class to handle both???
>
> You sound very vexed by this question, but the answer seems self-evident to
> me. You just do. It's totally up to you what your classes do and how you
> use them. Nobody's standing in your way.
Surprisingly, this sort of problem comes up fairly frequently, where
an inexperienced guy doesn't know where to start, and an experienced
guy doesn't even see where the problem is. Just do it! He says. But
how?
Obviously the answer depends a lot on what you're trying to do. But in
my opinion, the best generalized answer to this question is to "break
it down". In other words, break your problem into sub-problems. Repeat
on the sub-problems and their sub-problems and so forth until you're
left with teeny little problems that you know how to solve directly.
For more elaboration on this, see:
http://www.cocoadev.com/index.pl?BreakItDown
Of course this is not always a simple thing to do. You could
convincingly argue that being able to "break it down" well is, in
fact, what being a programmer really is. But in general I find that
thinking explicitly about how to decompose my bigger problems into
smaller problems, rather than thinking directly about how to solve my
bigger problems, helps a great deal.
In this case, the fundamental problem is that you have a bunch of
duplicated code alongside a bunch of unique code, and this is
obviously bad. How can you factor out that duplicated code into a
single place? Two possibilities spring to mind: put it into a common
superclass, or move it into a helper object. Each one of those can be
broken down further. If you move it into a common superclass, you have
to think about where that class would be in the hierarchy, what code
it would contain, how it will communicate, etc. If you create a helper
class, you'll have to create the interface for it, create
notifications or delegate methods for it to talk back, etc. Each of
these then decomposes further into smaller sub-problems.
I hope this is helpful. This sort of generalized programming
problem-solving skill takes some time to learn (and a lifetime to
master), but this is, I think, the main guiding principle to work
with.
Mike
_______________________________________________
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