• 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: All seems well but image doesn't show up.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: All seems well but image doesn't show up.


  • Subject: Re: All seems well but image doesn't show up.
  • From: Steve Bird <email@hidden>
  • Date: Mon, 23 Jul 2007 07:13:23 -0400


On Jul 22, 2007, at 10:30 PM, David Arnold wrote:

Commenting out the code

/*
 - (void)drawRect:(NSRect)rect {
    // Drawing code here.
}
*/

cured the problem.

However, I am so new to this, I can't say that I "see" the problem. I used the File Assistant to subclass an NSView class, so the drawRect command was put there by the XCode machinery. A naive guess would be that an empty drawRect method would cause an empty NSView,

--- Not so naive. When you're commanded to draw the view (or part of it), and you respond by doing nothing, then nothing is exactly what shows up.




but I cannot say for certain why the lines

- (void)windowDidLoad
{
	NSImage *image = [[self document] activeImage];
	NSLog(@"%@",image);
	[view setImage:image];

in the IAWindowController still don't provide an image.

--- They did provide the image.... to the view. But the view did nothing with it. The default drawRect: method takes the image it has and puts it on screen. But since you overrode the default with your own method which does nothing, then nothing is what you get.





And finally, when we get ourselves into these situations, other than pouring
--- that would be "poring".

over the code again, what good ideas come to mind to debug the source of the problem?
--- The only solution here is to understand what is "supposed" to happen. If you aren't aware that the drawRect: method is responsible for ALL drawing into the view, then stepping thru the code will not reveal anything until you pull your hair out to reveal your scalp.
If your code works the way it's supposed to, then you have to be willing to question whether your suppositions are wrong.


"It's not what you don't know that hurts you, it's what you do know that ain't so."
--Will Rogers



---------------------------------------------------------------- Steve Bird Culverson Software - Elegant software that is a pleasure to use. www.Culverson.com (toll free) 1-877-676-8175


_______________________________________________

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


References: 
 >All seems well but image doesn't show up. (From: David Arnold <email@hidden>)
 >Re: All seems well but image doesn't show up. (From: Chris Suter <email@hidden>)
 >Re: All seems well but image doesn't show up. (From: David Arnold <email@hidden>)

  • Prev by Date: Simple view in NSScrollView
  • Next by Date: Re: Comparing NSDictionary woes
  • Previous by thread: Re: All seems well but image doesn't show up.
  • Next by thread: Noob: MainMenu.nib and MyDocument.nib targeting problems
  • Index(es):
    • Date
    • Thread