0

I have the classes.

@interface USSAppController : NSObject
{
    USSWindowController *windowController;
}

-(IBAction)startLesson:(id)sender;

-(IBAction)endLesson:(id)sender;

@end



@implementation USSAppController

-(IBAction)startLesson:(id)sender
{

isLesssonRunning = true;

if(isLesssonRunning)
{       
    windowController = [[USSWindowController alloc] initWithWindowNibName:@"Lesson"];

    [windowController showWindow:self];
}
}

-(IBAction)endLesson:(id)sender
{
[windowController close];
}

@end

I was wondering if i could pass one variable from one class that to another when the window is created on button press?

madLokesh
  • 1,860
  • 23
  • 49
Joshua Blevins
  • 689
  • 1
  • 10
  • 27

2 Answers2

0

Create your own custom init method in USSWindowController which initializes the windowNibName and set the variable which you are passing.

- (id)initWithNibName:(NSString *)nibName variable:(NSString)*var1
{
    self = [super initWithNibName:nibName];
    if (self) {
        self.<instance variable> =  var1;

    }

    return self;
}
0

If you want to pass variable data from one nib to another, you can always rely on delegation.

Here's a simple answer

using-delegates-in-multiple-view-controllers

Community
  • 1
  • 1
madLokesh
  • 1,860
  • 23
  • 49