Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
- Subject: Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
- From: Graham Cox <email@hidden>
- Date: Sat, 21 Jun 2008 15:19:55 +1000
You observation is helpful. I thought that I needed to create a view
class. I also thought that with this view class it would have an
IBAction (the popup button connected to this) with a switch
function, with each case setting an ivar which would be returned to
the controller class through getter in the controller when the
button was pressed. I you get what I mean. Am I going the "long way
round" by doing this?
So have I gone too far with the idea of abstraction?
By your observation, I should lose the view class I created and
connect an IBAction in the controller to the popup button?
Looking at your nib file (which at least I can open), the pop-up
button is not connected to anything at all, which is probably why it's
not doing anything.
Also, you have a generic custom object set to "View". That's incorrect
- Views are any specific widget or control (in fact any NSView
subclass) that you use in IB, so your Button and the Pop-up are
already views. You don't need to instantiate one as a standalone
custom object - remove it.
Your pop-up button should send its action to the controller. That's
where the "popUpChoice:" method (or whatever) would go. You don't need
a View object as you have created it. The controller in turn will
invoke methods on the model to set its state. Generally controllers
contain lots of "glue code" which interprets stuff coming from the
views (controls) and translate that to state changes in the data
model, and vice versa.
Custom views are often created, but not in the way you've done it.
Instead you drag a "custom view" to a window (typically) and set its
class. However at this stage I don't think you need to know about this.
Graham
On 21 Jun 2008, at 2:56 pm, Jason Wiggins wrote:
Thanks Henry for your response. I'll have to read that a couple
times to let it sink into my thick skull. Not sure why the DL link
is zero length. Here is a better link: http://members.optusnet.com.au/jwiggins/xcode/TestCase.zip
The reason I connected things in the way I did was to understand
what was and wasn't happening. But then again, as stated, I'm doing
something fundamentally wrong.
_______________________________________________
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