Background: I'm a .NET guy who has no prior experience in Objective-C/Cocoa, but I'm working through Aaron Hillegass' book, "Cocoa Programming for Mac OS X" trying to pick up the basics. (Great book so far, BTW!) For the purpose of completing one of the optional side challenges, I'm writing a document-based app that lets users draw ovals in arbitrary locations.
I have two classes, interfaces as follows:
@interface OvalDrawDocument : NSDocument
{
IBOutlet OvalView* myOvalView;
}
@end
@interface OvalView : NSView {
NSMutableArray *ovals;
}
@property (readwrite, assign) NSMutableArray *ovals;
@end
In the implementation of OvalDrawDocument
I'm trying to use the auto-generated property accessor for ovals
like so:
// in OvalView.m
@synthesize ovals;
// in OvalDrawDocument.m
[myOvalView setOvals:loadedOvals]; // setter?
NSMutableArray *ovalsToSave = [myOvalView ovals]; // getter?
However, the compiler warns me that the methods aren't found, and they don't work at runtime either. They appear in Code Sense, but I guess that doesn't really mean anything (Still getting used to the differences between XCode/VS here) I'm guessing there's some Obj-C concept I'm not quite grasping here, possibly related to the fact that myOvalView
is also an IBOutlet
, but I'm pretty lost. What should I be doing, and more importantly, why?
Update: I didn't declare OvalView.h in OvalDrawDocument.m. Doing so fixed the compilation warnings. However, saving and loading still don't seem to work and I can't figure out why.
As requested, I've posted the full source code online for perusal: Browse or Download (59KB zip).