I'm having a bit of a confusion on how to assign a value to a BOOL pointer? Here's my code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.latitude.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
self.longitude.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.longitude];
if (!initialBroadcast) {
initialBroadcast = YES; // Where I'm having troubles
[broadcastTimer fire];
};
}
The compiler keeps telling me this: Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'BOOL' (aka 'signed char')
.
I'd appreciate a clarification on this since I am a nubski.
UPDATE
As many of you have pointed out, I am apparently abusing the declaration of a BOOL
by using a pointer for it. To be honest, I don't know why I used it, but since I'm new to Objective-C it must have worked for what I was doing so it stuck.
Anyway, I have since changed the declaration to:
// In .h
@interface ... {
BOOL initialBroadcast;
}
@property BOOL initialBroadcast;
// In .m
@synthesize initialBroadcast;
So, am I on the right track now?
question from:
https://stackoverflow.com/questions/5364506/how-to-assign-a-value-to-a-bool-pointer-in-objective-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…