I have 2 classes: AppDelegate and ViewAddFriendsWindowObject.
In AppDelegate.m i have these lines of codes:
#import "ViewAddFriendsWindowObject.h"
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
ViewAddFriendsWindowObject *viewAddFriends = [[ViewAddFriendsWindowObject alloc] init];
[viewAddFriends isFirstRun:YES];
}
In ViewAddFriendsWindowObject.h i have:
#import <Foundation/Foundation.h>
@interface ViewAddFriendsWindowObject : NSObject
@property IBOutlet NSButton *cancelSkipBtn;
@property IBOutlet NSButton *doneBtn;
- (void)isFirstRun:(BOOL)firstRun;
@end
In ViewAddFriendsWindowObject.m i have:
#import "ViewAddFriendsWindowObject.h"
@implementation ViewAddFriendsWindowObject
@synthesize cancelSkipBtn=_cancelSkipBtn;
@synthesize doneBtn=_doneBtn;
- (void)isFirstRun:(BOOL)firstRun{
NSLog(firstRun ? @"Yes" : @"No");
if(firstRun == YES){
NSLog(@"YES");
[_cancelSkipBtn setTitle:@"Skip"];
[_cancelSkipBtn setEnabled:NO];
}else{
NSLog(@"NO");
[_cancelSkipBtn setTitle:@"Cancel"];
}
}
@end
Here’s the problem. The NSLog(@"YES") is executed but [_cancelSkipBtn setTitle:@"Skip"]; and [_cancelSkipBtn setEnabled:NO]; are not. Any ideas?
When you alloc and init an object in code, you are bypassing any connections you made in IB. Therefore, your IBOutlet properties are not being set to anything before you call
isFirstRunon it