Re: Drag 'n Drop 'n Delegation Dilemma
Re: Drag 'n Drop 'n Delegation Dilemma
- Subject: Re: Drag 'n Drop 'n Delegation Dilemma
- From: Michael Gersten <email@hidden>
- Date: Sun, 23 Jun 2002 11:06:19 -0700
Christophe Dore wrote:
>
Well, you can always poseAs NSView... It's in fact a same but simpler
>
(less bug-prone, i Think) way than global dictionary +category to add
>
ivars in all views.
PoseAs still does not let you add more ivars. Not directly, anyways.
>
Note that I don't slightly recommand poseAs: as a solution to any
>
problem. But when you come to consider either to subclass every NSView
>
subclass (what an effort !!), of handle a bug-prone and slowness-source
>
global dictionary to simulate more ivars, sometimes what should be
>
considered as a 'dirty trick' becomes the badless solution
>
>
Brian Webster wrote:
>
> ...
>
> If I had
>
> designed the system, I probably would have given NSView some sort of
>
> "drag delegate" to handle dragging messages. This is a hard thing to
>
> do after the fact, though, since you can't add instance variables to
>
> an existing class like you can add methods using categories. I
>
> suppose one way around this would be to have some sort of global
>
> dictionary that maps NSViews onto their delegates, but that would
>
> bring up a whole other slew of issues.
Ok, two people now have said that adding more ivars via an external global dictionary is a bad idea.
I was under the impression that this was the way NeXT, err, Apple implemented the retain counts on objects. There is no available ivar in NSObject, and since any class can have undocumented indexed ivars (or has that hook finally been removed? I haven't checked since OS 4 days), it can't just be using the indexed data section of the object.
Other than locking the dictionary for multithreaded apps, what's the badness of this?
The only possible objection might be that the external delegate would be missed in -copy, but views aren't copyable.
Now, as to the IN-direct pose-as idea:
If it is still possible to request extra space when an object is allocated, can you "add" to the amount of extra space being requested by the rest of the class(es), and adjust returned pointer addresses accordingly? (I never did take a good look at the details of that API, just enough to see that it was there.)
Michael
--
I am a Mac 10-Cocoa/WOF/EOF developer, and I'm available for hire. Please contact me at michael-job @ stb.X-Mozilla-Status: 0009d. Resume at
http://resumes.dice.com/keybounce
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.