Let's say I have an NSInteger
set up in Class1 as so:
@property (nonatomic) NSInteger *amount;
In a method in Class1 I add 5 to amount, like so:
amount += 5;
Now in Class2, I want to be able to get the value of amount and display it in an NSLog. What is a way to do this? I tried:
shop = [[Shop alloc]init];
NSLog(@"%i", shop.amount);
but that doesn't work because it creates a new instance of shop every time I want to display amount, and I don't know how to fix that.
I can declare a global variable but I would like to stay away from those, so what other solutions are there?
Thanks.