Since most of us create views in code instead of Interface Builder these days, I came to think of what the IBOutlet and IBAction equivalents are in Obj-C.
Is it true that the equivalent of IBOutlet would be equivalent to setting the delegate of the property to the view controller, and IBAction would be equivalent to adding a target action, for example:
rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
//additional junk here
[rightButton addTarget:self action:@selector(firesRightButton) forControlEvents:UIControlEventTouchUpInside];
// off to mission accomplished
If someone could confirm (or just plain state the correct examples), that will be great.
The direct reason for this post is that I see IBOutlet declared in someone's code next to a property, when Interface Builder was not involved at all.
@interface SomeViewController : UIViewController
@property (nonatomic, weak) IBOutlet UISwitch *switch;
@end
What does this switch IBOutlet mean here, if Interface Builder was not even used in the project?
Yes we all know that both IBOutlet and IBAction do not resolve to anything after the pre-processor parses it...