Reputation: 426
Actually, i have some values calculated in my viewController.m of my project.And i use that final result in another class(uiview class) to draw that.But i can't understand how can i use the calculated values in my other class of same project in iphone.
Upvotes: 2
Views: 264
Reputation: 1433
Go with following steps
Declare the variables in delegate.h file
write @property for the variable
e.g.@property (nonatomic, retain) NSString *string;
Synthesize in delegate.m
@synthesize string;
In the class(.h) where you want to use it
//import yourDelegate.h YourDelegate *mainDelegate;
In .m file
mainDelegate = [[UIApplication sharedApplication]delegate];
Upvotes: 1
Reputation: 617
Before you push into your new view you can pass variables accross.
E.g.
ViewController * viewcontroller = [ViewController alloc] init;
//pass your variables in here by setting the variables in the view your pushing into
viewcontroller.calculation = self.calculation;
//push into new view
[self.navigationController pushViewController:viewcontroller animated:YES];
[viewcontroller release];
this allows you to set the variable calculation in your new class by making it equal your calculation variable on your original view, before pushing to the new view.
Upvotes: 0
Reputation: 3345
use setters and getters its essay for a beginner,or else go for property and synthesize.use this reference
Upvotes: 1
Reputation: 5644
When pushing a new view you can call methodes of that view. Don't know if that is what you are looking for.
Upvotes: 2