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: "Henry McGilton (Starbase)" <email@hidden>
- Date: Fri, 20 Jun 2008 21:35:47 -0700
On Jun 20, 2008, at 5:48 AM, Jason Wiggins wrote:
Hi everyone,
If possible, could someone please educate me on the fundamental
mistake in my understanding of use of classes/instances/
encapsulation/messaging. I have reread the Object-Oriented
Programming with Objective-C but didn't find my answer.
I have written a test program with three classes- Model, View and
Controller and a Window with a button and a popup button. There are
setters and getters to test getting data in/out of the Model Class,
which works as expected.
Okay, so you have a model, and you have a Controller, and you have a
View.
Where is this View ? Is it a sub-view of the window's content view ?
Both the Controller and View Classes are connected to the popup
button in IB.
Connected in what way ? Do you have a connection *from* the
Controller and
*from* the View to the popup button ? If so, why ? What do you
expect to
happen ? And what is the other button expected to do ?
Sounds like the connections are going in the wrong direction.
Let's ask the fundamental question: when the popup button changes
state, what do
you want to happen inside the program ?
If I were doing something like this, I would expect that the popup
button
changing state would send an action message to the controller to tell
the controller
there's been a change.
The controller would then tell the model to update its state, and
finally, the
controller would send the new state to the view and possibly tell the
view to
re-display itself.
What I want to do is have the View Class to return the value of the
selected index of the popup button, but all I ever get is 0. I get
the value OK from the Controller Class though. I am obviously doing
something fundamentally wrong or misunderstanding "something".
Here is the program:
ftp://email@hidden:21/xcode/TestCase.zip
That .zip file is a zero-length file . . .
The log below is not too helpful because it doesn't indicate which
object is
generating the log.
The console output I get is as such:
[Session started at 2008-06-20 22:39:25 +1000.]
2008-06-20 22:39:25.780 TestCase[1439:10b] AwakeFromNib called
2008-06-20 22:39:25.784 TestCase[1439:10b] AwakeFromNib called
2008-06-20 22:39:25.784 TestCase[1439:10b] AwakeFromNib dataString
is: Initial Value
// Select the second item from the popup button and press the button
2008-06-20 22:40:12.004 TestCase[1439:10b] dataString is: Initial
Value
2008-06-20 22:40:12.005 TestCase[1439:10b] dataString is:
2008-06-20 22:40:12.006 TestCase[1439:10b] dataString is: TESTING...
2008-06-20 22:40:12.007 TestCase[1439:10b] popUpButtonSelectedIndex
called and index of selected item is 0
2008-06-20 22:40:12.007 TestCase[1439:10b] View selected index is: 0
2008-06-20 22:40:12.008 TestCase[1439:10b] Controller selected
index is: 1
_______________________________________________
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