

#import "SecondViewController.h"
#import "TwoXibsAppDelegate.h"


@implementation SecondViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
	if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
		// Initialization code
	}
	return self;
}

- (IBAction)setRed:(id)sender {
	TwoXibsAppDelegate *md = (TwoXibsAppDelegate *)[[UIApplication sharedApplication] delegate];
	md.helloWorldColor = [UIColor redColor];
	[md flipViews:sender];
	//comment out the line above, and uncomment these lines to send the message to the notification center to notify the delegate to change the value
	//of the helloWorldColor ivar
//	NSNotificationCenter *dc = [NSNotificationCenter defaultCenter];
//	[dc postNotificationName:@"DelegateFlipViewNotification" object:nil];
}

- (IBAction)setBlue:(id)sender {
	TwoXibsAppDelegate *md = (TwoXibsAppDelegate *)[[UIApplication sharedApplication] delegate];
	md.helloWorldColor = [UIColor blueColor];
	
	//send the notification that blue has been set. the receiver is the firstViewController ivar
	NSNotificationCenter *dc = [NSNotificationCenter defaultCenter];
	[dc postNotificationName:@"BlueIsSet" object:nil];
	[md flipViews:sender];
}

- (IBAction)setGreen:(id)sender {
	TwoXibsAppDelegate *md = (TwoXibsAppDelegate *)[[UIApplication sharedApplication] delegate];
	md.helloWorldColor = [UIColor greenColor];
	[md flipViews:self];
}

/*
 Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
 */

/*
 If you need to do additional setup after loading the view, override viewDidLoad.
- (void)viewDidLoad {
}
 */


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	// Return YES for supported orientations
	return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
	// Release anything that's not essential, such as cached data
}


- (void)dealloc {
	[super dealloc];
}


@end
