Question

I am new in iPhone app. I want to show a mesage at each 2 seconds when a button is pressed For that I am using this code.

This code is work only one time. That means call only one time. Can you help me to solve this problem.

-(IBAction)fortunecookieAction:(id)sender
{
    [self performSelector:@selector(showfortune) withObject:nil afterDelay:2.0];
}

-(void)showfortune
{
    int number=arc4random()%5;
    switch (number) {
        case 0:
            fortunelabel.text=@"A holiday takes you back to the summer of '69";
            break;
        case 1:
            fortunelabel.text=@"A meal turns erotic muffin";
            break;
        case 2:
            fortunelabel.text=@"A massage brings";
            break;
        case 3:
            fortunelabel.text=@"A letter in the pa special delivery";
            break;
        case 4:
            fortunelabel.text=@"A spillage tuoo";
            break;

        default:
            break;  
    }   
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top