I’m making an app that when you press a button it give you a random image. When I run it I don’t get any error, but when I click on the button the app freeze and on xcode it says “Thread 1: breakpoint 1.1” at the end of this code right here:
-(void)changeLabel{
progressView.progress += 0.15;
if (progressView.progress == 1) {
label.hidden = YES;
progressView.hidden = YES;
[timer invalidate];
imagenesTest.hidden = NO;
int randomNumber = arc4random() % 4;
switch (randomNumber) {
case 0:
imagenesTest.image = [UIImage imageNamed:@"image1.png"];
break;
case 1:
imagenesTest.image = [UIImage imageNamed:@"image2.png"];
break;
case 2:
imagenesTest.image = [UIImage imageNamed:@"image3.png"];
break;
case 3:
imagenesTest.image = [UIImage imageNamed:@"image4.png"];
default:
break;
}
}
}
When I press a button it supposed to active a progress bar and then put the random image. It gives the error before the progress bar starts working. Here is the code I have for the button:
- (IBAction)scan:(id)sender {
label.hidden = NO;
imagenesTest.hidden = YES;
progressView.hidden = NO;
progressView.progress = 0;
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeLabel) userInfo:nil repeats:YES];
}
When I click on the thread, it highlights me this
0x94feb6: jmp 0x3ef05
; -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 4724
Am I doing something wrong with the code? Sorry if I didn’t explain myself well, I started programming a some months ago
Thank you, Emilio
IF that is all the information the console is telling us, this is not an error message, it means you added a breakpoint. Beside your code, you will see a gutter line, if you press it you can add breakpoints which are these blue arrow things. Here is an image:
So to unselect the breakpoint, just click it or right click it and press delete.
Also to disable breakpoints: command+Y or press the breakpoints select button at the top near the stop button and the scheme bar and the build status bar
Check my answer to this recent similiar question:
iPhone app simple calculator – objective c error
UPDATE:
Can you put some
NSLogthat check if the image is valid and that methods are being called. Tell me your results!NSLogis basically logging into the debugging console. So addNSLog(@"test");into your method and if it gets printed into the console you know the method has been calledAlso maybe put an
ifstatement sayingThat statement’s condition takes place only if
imageis non-zero/valid/initialized. Thereforeshould be printed in the debugging console