我一堂课有 7 种方法。当我收到特定消息时,我必须从这 7 个方法中随机调用一个方法。我的示例代码是:
-(void)poemAbcd{
UIImage *image = [UIImage imageNamed: @"abcd_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:80 with:220];
}
-(void)poemHumptyDumpty{
UIImage *image = [UIImage imageNamed: @"humpty_dumpty.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:80 with:170];
}
-(void)poemBlackship{
UIImage *image = [UIImage imageNamed: @"black_sheep.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:66 with:229];
}
-(void)poemRowRow{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemHappy{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemItsyBitsy{
UIImage *image = [UIImage imageNamed: @"boat_bg.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:144 with:211];
}
-(void)poemTwinkleTwinkle{
UIImage *image = [UIImage imageNamed: @"twincle_twincle_little_star.png"];
[backgroundImage setImage:image];
[self changeMumuPosition:70 with:222];
}
在下面的方法中,我想从这 7 个方法中随机调用一个方法。
-(void)poemRandom{
//Call a method randomly from those 7 methods
}
我该怎么做?在此先感谢您的帮助。