[Drawkit] get tool controller?
James Maxwell
jbmaxwell at rubato-music.com
Tue Feb 17 15:35:05 PST 2009
Thanks Graham,
I haven't been using DrawKit for a while, because I've been working on
other things, so thanks for reminding me about [[self drawing]
controllers]. I most surely have broken certain aspects of MVC - I do
have two views in my main document window, with two separate
controllers. There are specific reasons for this in my overall design,
but it's kind of complicated.
I do have another question, though... I have a class which initializes
just fine, and seems fine, but when I try to use one of its methods, I
find that one of its instance variables contains a completely foreign
object - and this changes arbitrarily! I'm guessing there's something
somewhere that's been freed, leaving my instance variable is pointing
to some garbage space, but I've no idea how to track down the problem.
Any tips? I haven't had this problem, so far...
thanks,
J.
On 17-Feb-09, at 3:25 PM, Graham Cox wrote:
>
> On 18 Feb 2009, at 9:57 am, James Maxwell wrote:
>
>> ignore this... I realized it would be simpler to use a notification.
>>
>> cheers,
>>
>> J.
>>
>>
>> On 17-Feb-09, at 12:46 PM, James Maxwell wrote:
>>
>>> I need to get the tool controller from my DKObjectDrawingLayer -
>>> how do I do that?
>>> It's a DKDrawingDocument-based app.
>>
>
>
> On a general note, sometimes the 'need' to do things like this can
> be a sign of something amiss in your design. A code smell, as some
> call it. In Model-View-Controller, model objects (such as the layer)
> don't generally need to have a deep knowledge of the controller(s),
> except typically to inform them in a general way that something
> changed. The inverse isn't true - controllers typically do have deep
> knowledge of the model objects they control.
>
> You *can* get the controllers from a layer:
>
> [[self drawing] controllers];
>
> But note that this returns a set (list) of controllers. In most
> designs there will probably be only one, but you can't assume (and
> DK sometimes inserts temporary controllers into this list for some
> operations). Being a set, the list is unordered. Again this tells
> you that no controller is any more or less important than any other.
> Getting a specific controller requires more knowledge, such as which
> view it is associated with, by which time you've well and truly
> broken MVC.
>
> If you want to tell me what you're trying to do, I can advise further.
>
> --Graham.
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net
More information about the Drawkit
mailing list