NewOrder -1 Posting Whiz

i wrote this book as it was presented in the book:

header:

#import <UIKit/UIKit.h>
#define degreesToRadians(x) (M_PI*(x)/180.0)

@interface SwapViewController : UIViewController {
	IBOutlet UIView *landscape;
	IBOutlet UIView *portrait;
	
	//Foo
	IBOutlet UIButton *landscapeFooButton;
	IBOutlet UIButton *portraitFooButton;
	
	//Bar
	IBOutlet UIButton *landscapeBarButton;
	IBOutlet UIButton *portraitBarButton;
	
}


@property (nonatomic, retain) UIView *portrait;
@property (nonatomic, retain) UIView *landscape;
@property (nonatomic, retain) UIButton *landscapeFooButton;
@property (nonatomic, retain) UIButton *portraitFooButton;
@property (nonatomic, retain) UIButton *landscapeBarButton;
@property (nonatomic, retain) UIButton *portraitBarButton;

-(IBAction)buttonPressed:(id)sender;

@end
#import "SwapViewController.h"

@implementation SwapViewController

@synthesize landscape;
@synthesize portrait;
@synthesize landscapeFooButton;
@synthesize portraitFooButton;
@synthesize landscapeBarButton;
@synthesize portraitBarButton;

-(void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation )toInterfaceOrientation duration:(NSTimeInterval )duration
{
	
	if(toOrientation   ==UIInterfaceOrientationPortrait) // toOrientation undeclared
	{
		self.view=self.portrait;
		self.view.transform=CGAffineTransformIdentity;
		self.view.transform=CGAffineTransformMakeRotation(degreesToRadian(0));
		self.view.bounds=CGRectMake(0.0, 0.0, 300.0, 480.0);
	}
	else if(toOrientation ==UIInterfaceOrientationLandscapeLeft)
	{
		self.view=self.landscape;
		self.view.transform=CGAffineTransformMakeRotation(degreesToRadian(-90));
		self.view.bounds=CGRectMake(0.0, 0.0, 460.0, 320.0);
	}
	else if(toOrientation==UIInterfaceOrientationPortraitUpsideDown)
	{
		self.view=self.landscape;
		self.view.transform=CGAffineTransformIdentity;
		self.view.bounds=CGRectMake(0.0, 0.0, 300.0, 480.0);
	}
	else if(toOrientation==UIInterfaceOrientationLandscapeLeft)
	{
	    self.view=self.landscape;
		self.view.transform=CGAffineTransformIdentity;
		self.view.transform=CGAffineTransformMakeRotation(degreesToRadian(90));
		self.view.bounds=CGRectMake(0.0, 0.0, 460.0, 320.0);
	}
	
}


-(IBAction)buttonPressed:(id)sender
{
	if(sender== portraitFooButton || sender==landscapeFooButton)
	{
		portraitFooButton.hidden=YES;
		landscapeFooButton.hidden=YES;
		
	}
	else 
	{
		portraitBarButton.hidden=YES;
		landscapeBarButton.hidden=YES;
	}
	
	
}


-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation )toInterfaceOrientation{
	return YES;	
}





- (void)dealloc {
	[portrait release];
	[landscapeFooButton release];
	[portraitFooButton release];
	[landscapeFooButton release];
	[portraitBarButton release];
    [super dealloc];
}

it gives me an error that says toOrientation isnt declared. but it should be declared automatically, cause the xcode helps me to type the variable straight way!! why do i experience that error!?


also is this the most efficient way to rotate the screen or is there a better way?