I have a float value in a custom class (named DrawingLayer) declared as:
Code:
float totalTimeDifference;
@property(readwrite, assign) float totalTimeDifference;
I also synthesize it with:
Code:
@synthesize totalTimeDifference;
The class named DrawingLayer is an MKMapViewDelegate. I do some operations on this float value in the didUpdateUserLocation method:
Code:
NSTimeInterval difference = [userLocation.location.timestamp timeIntervalSinceDate:lastUserLocation.timestamp];
self.totalTimeDifference = self.totalTimeDifference + (float)difference;
It works well, I can output the float to a label in the application, so I know it gets incremented (and works).
However, in a separate method of the DrawingLayer class, I try to output this float value to the NSLog:
Code:
NSLog(@"The total time difference is: %f.", self.totalTimeDifference);
When I try to output it, the float value is always 0.000000! Am I not setting its property correctly? I'm not sure what the problem is. Can someone please help me out and tell me what is going on here? I haven't got the slightest clue! I don't get why it works in one method, but not this one. Does it get retained locally or something!? I need to pass this value to a method in another class, so I really need to be able to get its float value!