I suspect appWindow is nil, which you can check with one more NSLog:

    NSLog(@"appWindow is %@", appWindow);

Your init method is being called before the nib file has completely loaded, so not all the connections have been made yet. Try adding an awakeFromNib method and moving your code there. Also, double-check that you've connected the AppController's appWindow outlet in IB.

<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSNibAwaking_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/awakeFromNib >

--Andy


On May 30, 2009, at 10:27 AM, cocoa learner wrote:

Thanx Nick for your reply.But in my window I am not getting the image I want
to display. Here is my code -

- (id) init

{

[super init];

NSLog(@"AppController::init : Setting the windows content");

NSBundle *myBundle = [NSBundle mainBundle];

if (myBundle == NULL)

{

NSLog(@"AppController::init : myBundle is NULL");

}

else

{

NSLog(@"AppController::init : myBundle is not NULL");

}

NSString *path = [myBundle pathForResource:@"winImg" ofType:@"png"];

NSLog(@"AppController::init : Image file path : %@", path);

NSImageView *winContent = [[NSImage alloc] initWithContentsOfFile:path];

[ appWindow setContentView: winContent];

NSLog(@"AppController::init : The windows content has been set");

return self;

}

I can see all the logs. But not the image in back ground of my app window.
Am I doing any thing wrong in this code?

Regards
Cocoa.learner.


On Tue, May 26, 2009 at 11:12 PM, Nick Zitzmann <[email protected]> wrote:


On May 26, 2009, at 11:04 AM, cocoa learner wrote:

How to draw background image in my app window?


You could change the window's content view using -setContentView: to a view that will draw a background image, such as NSImageView... Of course, if you have any other controls in the content view that is being replaced, then
they'll be lost.

Nick Zitzmann
<http://www.chronosnet.com/>






_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com

This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to