Hello,
Here is the code to a problem that is driving me nuts.
TextEditorWindowController.h:
TextEditorWindowController.m:
ExampleWindow.h:
ExampleWindow.h
Anyhow, the window is displayed, and the "Hello" message appears in the text view. But when I make the call to helloKitty the message "Hello Kitty" is not printed. The pointer editorTextView is zero, so the message does not print. It is as if something has been autoreleased or a new object was created (not passing the same object). The method helloKitty IS called, it is just that the pointer is zero, as I mentioned. What am I doing wrong?
Here is the code to a problem that is driving me nuts.
TextEditorWindowController.h:
Code:
#import <Cocoa/Cocoa.h>
@interface TextEditorWindowController : NSWindowController {
NSTextView *editorTextView;
}
@property (nonatomic, retain)NSTextView *editorTextView;
- (void)helloKitty;
@end
TextEditorWindowController.m:
Code:
#import "TextEditorWindowController.h"
@implementation TextEditorWindowController
@synthesize editorTextView;
- (void)dealloc {
[editorTextView release];
[super dealloc];
}
- (void)helloKitty
{
[editorTextView setString:@"Hello Kitty"];
}
- (void) awakeFromNib
{
[editorTextView setString:@"Hello"];
}
- (id)init
{
self=[super initWithWindowNibName:@"TextEditor"];
if(self)
{
// Do init here
}
return self;
}
@end
ExampleWindow.h:
Code:
#import <Cocoa/Cocoa.h>
#import "TextEditorWindowController.h"
@interface ExampleWindow : NSWindowController {
TextEditorWindowController * winController;
}
@property (nonatomic, retain) TextEditorWindowController *winController;
@end
ExampleWindow.h
Code:
#import "ExampleWindow.h"
#import "TextEditorWindowController.h"
@implementation ExampleWindow
@synthesize winController;
// Other code here that opens the main window of the example
- (IBAction)newFile:(id)sender
{
// Open the New Window
winController = [[TextEditorWindowController alloc] init];
[winController showWindow:self];
[winController helloKitty];
}
- (void)dealloc
{
[winController release];
[super dealloc];
}
@end
Anyhow, the window is displayed, and the "Hello" message appears in the text view. But when I make the call to helloKitty the message "Hello Kitty" is not printed. The pointer editorTextView is zero, so the message does not print. It is as if something has been autoreleased or a new object was created (not passing the same object). The method helloKitty IS called, it is just that the pointer is zero, as I mentioned. What am I doing wrong?
Last edited by a moderator: