Reputation: 40
when I try to create an IBOutlet or an IBAction by linking my interface to the header file, I don't get the option to create one.
Yeah, this COULD be a duplicate but I havent found my answer yet on ANY other post!
Thanks :)
@property (assign) IBOutlet NSWindow *window;
- (IBAction)calculateClicked:(id)sender;
@property (weak) IBOutlet NSTextField *ATextField;
@property (weak) IBOutlet NSTextField *BTextField;
@property (weak) IBOutlet NSTextField *CTextField;
Upvotes: 0
Views: 555
Reputation: 437372
I'm not sure what kind of object you wanted to add your outlets/actions to, but one might infer from the presence of the window
reference that you're trying to add that to your app delegate. In that case, you just need to make sure that your app delegate appears in the list of objects, and that you've specified the base class for that app delegate:
If, however, you were using some custom controller object, you would drag an generic object from the library to your NIB's list of objects. Then specify the custom controller class for that object (MyController
in my example):
Having done that, when you drag your outlets/actions from the window to the assistant editor, in addition to the app delegate, your custom controller object interface/implementation files will be options that you can use.
My original answer was an iOS-centric answer. The above should describe the Cocoa equivalent. I'll keep this original answer here for reference.
Original answer:
In Interface Builder, make sure to specify the base class for the object you're linking the outlets to. If putting these outlets in a view controller, make sure your storyboard's scene has the view controller's class defined. And it's a little easier if your assistant editor is set to "automatic":
The above screen snapshot is relevant if you're using storyboards. If using NIBs, the idea is the same, but you need to make sure you set the NIB's file owner:
If your IBOutlet
references are in a UIView
subclass, you analogously have to specify the base class for your storyboard scene's view (or the NIB's view).
Upvotes: 2
Reputation: 1045
I've seen Xcode occasionally do this (bug). Closing/reopening Xcode has fixed it for me before.
Also, make sure that your interface file is Class is pointing to this class/header.
Upvotes: 0