I have two classes, firstView & secondView. In firstView.h
#import "SecondView.h"
#import "FirstView"
@interface FirstView : NSObject {
IBOutlet NSButton *test;
secondView *mySecond;
}
@property (nonatomic, retain) IBOutlet NSButton *test;
-(IBAction) buttonClicked:(id)sender;
@end
In firstView.m
#import "FirstView.h"
@implementation FirstView
@synthesize test;
-(IBAction) buttonClicked:(id)sender{
NSLog(@"HELLO!!!");
if (!mySecond) {
// If the second view controller doesn't exist yet, make it!
mySecond = [[secondView alloc] init];
}
[mySecond displayWindow];
}
@end
In secondView.h
#import
@interface SecondView : NSObject {
IBOutlet NSWindow *progressWindow;
IBOutlet NSButton *testNew;
}
@property (nonatomic, retain) IBOutlet NSButton *testNew;
- (void)displayWindow;
-(IBAction) buttonClickedNew:(id)sender;
@end
In secondView.m
#import "SecondView.h"
@implementation SecondView
@synthesize testNew;
- (id)init {
if (self = [super init]) {
NSLog(@"HAI!!");
[NSBundle loadNibNamed:@"Next" owner:self];
}
return self;
}
- (void)displayWindow {
if (![progressWindow isVisible]) {
NSLog(@"ON SECOND!!!");
[progressWindow setIsVisible:YES];
[progressWindow orderFront:nil];
}
}
-(IBAction) buttonClickedNew:(id)sender {
NSLog(@"GOOD!!!");
}
@end
But I am getting the output as....
Running… 2011-04-05 16:12:30.400 toDoListMac[6558:a0f] HELLO!!! 2011-04-05 16:12:30.402 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.404 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.406 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.408 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.409 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.410 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.411 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.413 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.414 toDoListMac[6558:a0f] HAI!! 2011-04-05 16:12:30.415 toDoListMac[6558:a0f] HAI!!
secondView 'init' is calling infinite times! Please..please...help me.....
What I am trying to do is... I want to open another xib/window on a particular action, say button click.... please help me...