0

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

emiliomarin
  • 362
  • 3
  • 22

1 Answers1

2

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 NSLog that check if the image is valid and that methods are being called. Tell me your results!

NSLog is basically logging into the debugging console. So add NSLog(@"test"); into your method and if it gets printed into the console you know the method has been called

Also maybe put an if statement saying

if (image) {
NSLog(@"image is valid");
}

That statement's condition takes place only if image is non-zero/valid/initialized. Therefore

image is valid

should be printed in the debugging console

Community
  • 1
  • 1
MCKapur
  • 9,127
  • 9
  • 58
  • 101
  • Thanks, now it doesn't stop working. But I can't get the random images working, it just doesn't appear. I have a UIImageView on the nib file and the IBOutlet on the h file... everything seems be good – emiliomarin May 14 '12 at 10:40
  • Thanks for your help and yes, it says in the console "Image is valid" I'm going to try making a new project, because I've testing stuff and maybe I screwed up something.. I don't really know – emiliomarin May 15 '12 at 00:08
  • Alright, it is working now. I don't know why it didn't work before. Thanks :) – emiliomarin May 15 '12 at 00:30