iphone sdk conditional in switch function

Posted by Oliver on Stack Overflow See other posts from Stack Overflow or by Oliver
Published on 2010-05-01T04:28:46Z Indexed on 2010/05/01 4:37 UTC
Read the original article Hit count: 342

Filed under:
|
|
|
|

I'm trying to make a random image appear on the press of a button. So it generates a random number, and the switch algorithm swaps the chosen image with the one in the imgview. but I want a switch in the settings app to toggle which set of images to use. I know pretty much how to do it...it's just that it doesn't work. I'm missing some syntax thing...Please help, stackoverflow? it's my birthday.

int Number = rand() %30;

NSString *toggleValue = [[NSUserDefaults standardUserDefaults] stringForKey:@"enabled_preference"];

switch (Number) {

        if (*toggleValue == 0) {
        case 0:
            picture.image = [UIImage imageNamed:@"1.png"];
            break;

        case 1:
            picture.image = [UIImage imageNamed:@"2.png"];

            break;}

else {

        case 0:
            picture.image = [UIImage imageNamed:@"3.png"];
            break;

        case 1:
            picture.image = [UIImage imageNamed:@"4.png"];

            break;}

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about SDK