I have two classes. I'm trying to access a property from Class2 in Class1 (both subclasses of UIImageView). The x property is 0 when accessing it from Class1.
In Class2.h:
@interface ...
{
int x;
}
@property (readwrite, nonatomic) int x;
In Class2.m:
@synthesize x;
- (void)mainMethod
{
x = 4;
[NSTimer scheduledTimerWithTimeInterval:0.02
target:self
selector:@selector(updateX)
userInfo:nil
repeats:YES]
}
- (void)updateX
{
x += 5;
}
In Class 1:
- (void)mainMethod
{
Class2 obj = [[Class2 alloc] init];
NSLog(@"%i", obj.x);
}
Have I done something wrong in the code provided or is the problem caused by something else?