I'm creating a cocoa app with NSDocument architecture. Now I'm trying to save some data to a plist file inside dataOfType:error. Strange enough, every property in my document instance prints null when I try to access it inside that method.
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError{
NSLog(@"dataOfType was called");
NSLog(@"%@", self.properties); // prints (null)
NSLog(@"%@", window); // prints (null)
NSLog(@"dataOfType was called, done ");
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
return nil; }
Now when I do the same NSLog() in an action called via Button hooked up in Interface Builder, everything works as expected. It must be a pretty stupid fail by me.. but I don't get it. If I was working with JavaScript I'd think dataOfType:error was called with a different scope, where those properties are not available.. but I'm not as experienced in Objective-C and Cocoa obviously.