I JUST started a new XCode Project. The code I have added in so far is this:
.h
@interface GameScreen : UIViewController {
IBOutlet UIImageView *pimple;
IBOutlet UILabel *label;
}
@property (nonatomic, retain) UIImageView *pimple;
-(void)checkcollision;
.m
@synthesize pimple;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [[event allTouches] anyObject];
pimple.center = [myTouch locationInView:self.view];
[self checkcollision];
}
- (void)checkcollision {
if (label.text = @"0") {
label.text += 1;
}
}
My debugging console only sais one line:
Program received signal: “EXC_BAD_ACCESS”.
kill
Pls help
label.text += 1;is wrong. You can’t add an integer onto anNSStringobject.you will have to do
label.text = [NSString stringWithFormat:@"%d", ([label.text intValue] + 1)];