• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: +poseAsClass and instance variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: +poseAsClass and instance variables


  • Subject: Re: +poseAsClass and instance variables
  • From: Darrin Filer <email@hidden>
  • Date: Sat, 23 Feb 2002 01:29:58 -0500

I'm actually having a class pose as NSThemeFrame. Subclassing an NSWindow isn't terribly effective. NSBorderlessWindows don't have have hardware accelerated window dragging. Nor have I found a way to access HW accelerated dragging from anywhere but the title bar. Thus, I had to dip into the private APIs (with significant assistance from a helpful Swede.)

Is there an easier way to draw into a window's title bar? While I'm at it, I draw quite a bit of stuff so its necessary to access a static dictionary quite frequently. The other option is to load the values at the start of each instance method.

darrin filer


On Friday, February 22, 2002, at 04:05 PM, email@hidden wrote:

Is there anyway around the limitation that classes can't have instance
variables when posing as another class? For my purposes, categories
aren't suitable since I need to ensure that certain methods are
overridden.

You can override methods in categories, just not easily use the
original implementation. But on the over side, you cannot add instance
variables in categories either.

One solution is to store your additional variables in a (static)
NSDictionary, using the instance pointer as the key.

Thanks... Although I'm still looking for a technique with very little
overhead.

Explanation:
I'm using posesAsClass to replace normal NSWindows with ones that are
visual quite different. Most of the instance variables will be used
while drawing during live window resizing. Hence, optimization is sorely
needed. Dictionary lookup is nicely optimized but its still a noticeable
hit when compared to merely accessing an object's value. (right?)

It is slower than a direct ivar access, yes. Nevertheless, the overhead should be utterly negligible compared to the overhead of actually redrawing the window at the new size. I wouldn't worry about this at all. If you *did* find that the dictionary access was slowing you down, using Sampler or something, then you could try to optimize the dictionary lookup in various ways. But from your description of what you're doing, it won't be a problem.
Is there a reason you have to use posing rather than just using a subclass of NSWindow, by the way? Using posing is almost always the wrong solution for a given problem, although certainly there are exceptions. Even if the system is creating the windows for you and you have no control over the class (and I don't know what part of Cocoa would be doing that), you might still be able to do what you want by tweaking the isa pointers of those windows, which is much less invasive and dangerous than posing...

Ben Haller
Stick Software
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: +poseAsClass and instance variables
      • From: Dennis De Mars <email@hidden>
    • Re: +poseAsClass and instance variables
      • From: email@hidden
References: 
 >Re: +poseAsClass and instance variables (From: email@hidden)

  • Prev by Date: Re: Disk Image build in PB
  • Next by Date: Re: +poseAsClass and instance variables
  • Previous by thread: Re: +poseAsClass and instance variables
  • Next by thread: Re: +poseAsClass and instance variables
  • Index(es):
    • Date
    • Thread