• 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
Subclassing question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Subclassing question


  • Subject: Subclassing question
  • From: John Scalo <email@hidden>
  • Date: Wed, 22 Jan 2003 22:28:30 -0800

I want to subclass NSView so that it has a setVisible: method. Say I call it
HidingView. The details of doing that are no problem, but how do I go about
making things that are already subclasses of NSView (e.g.
NSProgressIndicator, NSImageView, etc) inherit from this subclass rather
than NSView? Sure I could subclass those subclasses every time and take care
of things there, but it sure would be convenient if I could just have all
subclasses of NSView inherit from HidingView so I could hide things when I
need to. Categories are almost perfect except...no instance variables. What
am I missing?

PS here's the simple subclass

- (void)setVisible:(BOOL)b
{
if (!b)
{
if (![self isVisible])
return;
savedFrame = [self frame];
[self setFrame:zeroFrame];
[self setNeedsDisplay:YES];
}
else
{
if ([self isVisible])
return;
[self setFrame:savedFrame];
[self setNeedsDisplay:YES];
}
}

- (BOOL)isVisible
{
NSRect visRect = [self visibleRect];

return (visRect.size.width != 0);
}
_______________________________________________
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: Subclassing question
      • From: John Scalo <email@hidden>
  • Prev by Date: deform a window
  • Next by Date: Re: Table View Headers Programatically
  • Previous by thread: Re: deform a window
  • Next by thread: Re: Subclassing question
  • Index(es):
    • Date
    • Thread