Hi, I can't figure out this.
I have MyDocument class which inherits from NSDocument and DocView which intherits from NSView. DocView has IBOutlet to MyDocument. When I working inside DocView and I want to get some information from my MyDocument object, I get "null".
DocView.h:
MyDocument.h
And let's say code in DocView will be like this:
So I launch my application, press File, Open, I will choose my last saved file, MyDocument becomes initialized and it's time to initialize docView and it should write "Rand: YES" into the Log (rand always gives YES in this example), but I get "Rand: (null)". So why can't I contact my MyDocument?
In Interfeice Builder there is connection from CustomView (DocView) to File's Ower (MyDocument).
I have MyDocument class which inherits from NSDocument and DocView which intherits from NSView. DocView has IBOutlet to MyDocument. When I working inside DocView and I want to get some information from my MyDocument object, I get "null".
DocView.h:
#import <Cocoa/Cocoa.h>
@class MyDocument;
@interface DocView : NSView {
IBOutlet MyDocument *doc;
}
@end
MyDocument.h
#import <Cocoa/Cocoa.h>
@interface MyDocument : NSDocument
{
}
- (BOOL)rand;
@end
And let's say code in DocView will be like this:
- (id)initWithFrameNSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
NSLog(@"Rand: %@", [doc rand]);
...
...
So I launch my application, press File, Open, I will choose my last saved file, MyDocument becomes initialized and it's time to initialize docView and it should write "Rand: YES" into the Log (rand always gives YES in this example), but I get "Rand: (null)". So why can't I contact my MyDocument?
In Interfeice Builder there is connection from CustomView (DocView) to File's Ower (MyDocument).