Allocating outlets from NIB file
Allocating outlets from NIB file
- Subject: Allocating outlets from NIB file
- From: Joseph Ayers <email@hidden>
- Date: Tue, 24 Jun 2008 08:17:17 -0400
- Organization: Northeastern University
I am quite confounded with regard to how/when to allocate outlets which
are classes existing as instances in
another class. Consider
@interface SpriteController : NSWindowController {
IBOutlet SpriteView* spriteView;
IBOutlet NSWindow* spriteWindow;
}
SpriteController* spriteController;
- (id)spriteWindow;
- (id)spriteView;
-(void)setSpriteView:(SpriteView*)view;
}
SpriteView is defined in another subclass as:
@interface SpriteView: NSView
{
NSImage *spriteImage;
}
SpriteController and SpriteView are defined and connected in the NIB
When I open the NIB with
-(void)loadSpriteController{
if (spriteController == NULL) {
spriteController = [[SpriteController alloc] init];
if (![NSBundle loadNibNamed:@"spriteWindow"
owner:spriteController]) {
NSLog(@"Error loading SpriteController");}
else{
NSLog(@"SpriteController NIB Loaded");
}
}
}
spriteController gets a pointer, but spriteView is NIL. All subsequent
messages to spriteView are
messages to NIL
How/where should I be allocating spriteView. I've tried adding:
[self setSpriteView: [[SpriteView alloc] init]];
to loadSpriteController with no consequence. spriteView gets a pointer but
[[spriteController spriteView] drawRect:[[spriteController
spriteWindow] bounds]];
does not get to drawRect
ja
--
Joseph Ayers, Professor
Department of Biology and
Marine Science Center
Northeastern University
East Point, Nahant, MA 01908
Phone (781) 581-7370 x309(office), x335(lab)
Cellular (617) 755-7523, FAX: (781) 581-6076
Boston Office 444RI, (617) 373-4044
eMail: email@hidden
http://www.neurotechnology.neu.edu/
_______________________________________________
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