Reputation: 1987
I come from iOS programming background. Now I'm trying to write a application in Mac OSX. I'm trying to connect my button in my interface file MainWindow.xib to a ViewController, as I would normally do in iOS programming to partition out the methods. However, I am only able to connect the button to AppDelegate.h - why is this so? I'm not able to connect the button to any other file, I've tried NSViewController, NSWindowController. It's possible for me to proceed by dumping all the methods in AppDelegate.h, but if possible I would like to group the methods out logically according to file.
What's the correct method to do something like this in Mac OSX?
Thanks in advance.
Here is my AppDelegate
#import <Cocoa/Cocoa.h>
@class MainLoop;
@interface AppDelegate : NSObject <NSApplicationDelegate> {
}
@property (nonatomic, strong, readonly)IBOutlet NSWindow *window;
@property (nonatomic, strong, readonly)MainLoop *mainLoop;
@end
Upvotes: 0
Views: 626
Reputation: 46543
Follow these steps: Demo project here
- Create a new class derived from
NSWindowController
. In image it isOutletCollection
.
- Create an Object, set its class to OutletCollection.
- Make this object as delegate for window.
- Now you can create outlets.
Upvotes: 2