• 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
Noob question: Weirdness getting the bounds of an NSView...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Noob question: Weirdness getting the bounds of an NSView...


  • Subject: Noob question: Weirdness getting the bounds of an NSView...
  • From: Jim Anderson <email@hidden>
  • Date: Tue, 24 Mar 2009 10:46:17 -0700

Hey, folks,

I'm reasonably new to Cocoa developing.  I'm playing around with a subclass
of NSView which generates some stuff based on the size of the view.  The
code basically looks like:

-----------------------------
@interface FooView : NSView {
    NSRect myBounds;
}
- (void)doSomeStuff;
@end

@implementation FooView
- (void)doSomeStuff
{
    // myBounds at this point is set to {0, 0, 0.0, 0.0}, even if this is
called after drawRect is fired

    // This will set myBounds to {0, 0, 0.0, 0.0}
    myBounds = [self bounds];
}

- (void)drawRect: (NSRect)aRect
{
    myBounds = [self bounds];
}
@end
-------------------------

The weird thing is, when drawRect gets called, [self bounds] returns a
reasonable looking bounding rectangle.  When doSomeStuff gets called, [self
bounds] returns {0, 0, 0.0, 0.0}.  The extra weird thing is, if doSomeStuff
is called *after* drawRect gets fired, myBounds is {0, 0, 0.0, 0.0},
*despite* it being set to something reasonable in drawRect.

Any ideas what's going on here?

Cheers,
--

Jim

Fear is the dark room where the Devil develops his negatives.

  - Gary Busey
_______________________________________________

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

  • Follow-Ups:
    • Re: Noob question: Weirdness getting the bounds of an NSView...
      • From: Quincey Morris <email@hidden>
    • Re: Noob question: Weirdness getting the bounds of an NSView...
      • From: "Luca C." <email@hidden>
  • Prev by Date: Re: iPhone Tab bar Question
  • Next by Date: Re: How to get selected Item in a NSTableVIew
  • Previous by thread: Re: How to get selected Item in a NSTableVIew
  • Next by thread: Re: Noob question: Weirdness getting the bounds of an NSView...
  • Index(es):
    • Date
    • Thread