Reputation: 1453
I have two classes, classA and classB.
I navigated from classA to classB.
I set a value
Temp = 0;
in classB.
I popped back to classA from classB.
Now, I need to access Temp
value in classA.
how can I get that without setting the value in AppDelegate calss ?
Upvotes: 0
Views: 392
Reputation: 1
I guess, there are two ways to do this:
Upvotes: 0
Reputation: 44093
You should use a Property. Have a look at the apple tutorial
@interface MyClass : NSObject
{
NSString *value;
}
@property(copy, readwrite) NSString *value;
@end
@implementation MyClass
@synthesize value;
@end
In another class that has a instance of MyClass
myInstanceOfMyClass.value = @"hi"; // Sets the value to 'hi'
NSString* myString = myInstanceOfMyClass.value; // Gets the value :)
Upvotes: 1