Reputation:
I'm learning iPhone Dev and I'm stuck on something. I'm writing a simple calculator program, but when I try to connect one of the buttons on the calculator to the File Owner in Interface Builder I do not get any options:
.h file
@interface CalculatorViewController : UIViewController
{
CalculatorBrain *brain;
IBOutlet UILabel *label;
}
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operandPressed:(UIButton *)sender;
@end
.m file
#import "CalculatorViewController.h"
@implementation CalculatorViewController
- (IBAction)digitPressed:(UIButton *)sender
{
//not implemented yet
}
- (IBAction)operandPressed:(UIButton *)sender
{
//not implemented yet
}
@end
As far as I understand when I'm working with my CalculatorViewController.xib in interface builder if I try to connect a button to the file's owner I should have two options: 1. digitPressed 2. operandPressed
However, I do not get any options. Any ideas what I'm doing wrong?
Thanks.
Upvotes: 1
Views: 3256
Reputation: 1867
I encountered a similar issue. The problem was that I renamed the ViewController. The XIB file has the name of the view controller inside of it.
when it doesn't match the actual name of the UI View Controller class interface builder will act funny.
To fix it, open the XIB file as source code (right click it and use Open As source code) it's an XML file. find the name of the old controller and then change it to the correct name. I found it in the XML under:
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">xxxxxxViewController</string>
Upvotes: 0
Reputation: 119292
Upvotes: 3
Reputation: 73966
Are you dragging from the button to the owner or the other way around?
If you want to refer to an object in a nib from code, then you define an IBOutlet
and drag from the owner to the object.
If you want to refer to code from an object in a nib file, then you define an IBAction
and drag from the object to the owner.
Upvotes: 0