Getting data into a view (was Re: custom view won't update)
Getting data into a view (was Re: custom view won't update)
- Subject: Getting data into a view (was Re: custom view won't update)
- From: Alastair Houghton <email@hidden>
- Date: Tue, 11 Sep 2007 14:49:19 +0100
On 11 Sep 2007, at 13:24, Paul Bruneau wrote:
On Sep 11, 2007, at 8:16 AM, H M wrote:
It seems a little strange that an NSView subclass has IBActions/
IBOutlets... yet the above code seems to imply that.
hm, come to think of it, i'd say you're right, they should be in a
controller class. that means i have to access the variables using
accessor methods, but that shouldn't be a problem. the question
is, how do I get that controller class to update my view?
Please excuse me barging in to ask a quick question of someone: I
have a subclass of NSView also. It has an IBOutlet for its
controller. Is this the correct way to get data from the controller
to the view?
It's usually better to post a question in a new thread, rather than
invading an existing thread with another question.
However, the answer to your question is that it's *one* way to do it,
yes. A lot of the existing Cocoa views have a "dataSource" outlet
for this very purpose.
It isn't the only way, however. Some views hold data themselves
(though this is rare, and you run the risk that your view will be
abused as a data store, which breaks MVC quite badly). Also, some
views support Cocoa bindings as a way to get data into them, and you
can support bindings yourself if you like (though in order to bind to
them in IB, you need to make a palette, which is often a
disproportionate amount of work for simple bindable views). You can,
of course, bind things in code instead.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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