Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

spire.bt

macrumors newbie
Original poster
Apr 8, 2010
22
0
I have a simple question ( :confused: )


if I have this code in the app delegate .m file

Code:
-(void){

        [UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1.0];
		
		[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:NO];
		[settingsViewController.view removeFromSuperview];
		
		[self.window addSubview:[viewController view]];
		
		[UIView commitAnimations];
		[settingsViewController release];
		settingsViewController = nil;
[B]int variableX=10;[/B]

}

how can I get this var so i can use it in the other view

ex.
In the AppViewControler.m

Code:
-(IBAction)UsedVar{

Result = 2 + [B]variableX[/B];


printf("%d and",Result);

}

lets say "-(IBAction)UsedVar" is connected to a button
 
You have to put your variable in the .h file of the app delegate (so it has class scope instead of just method scope) and make your variable a property.

Then wherever with your variable you want to use it:

Code:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 

delegate.myvar = 1;
NSLog(@"%@",delegate.myvar);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.