load view randomly
hi i wished to randomly load a view. the views are called view1 view2 and view3 below is the code im using. can any one tell me the the code i should place in the case section to replace - (void)viewDidLoad self.view = view1; etc as this is not working thanks
- (void)viewDidLoad {
[super viewDidLoad];
NSString *title = nil;
开发者_如何学JAVA NSString *path = nil;
int Number = arc4random() % 3;
switch(Number) {
case 0:
- (void)viewDidLoad {
self.view = view1;
}
break;
case 1:
- (void)viewDidLoad {
self.view = view2;
}
break;
case 2:
- (void)viewDidLoad {
self.view = view3;
}
break;
switch(Number) {
case 0:
self.view = view1;
break;
case 1:
self.view = view2;
break;
case 2:
self.view = view3;
break;
}
You should remove the:
- (void)viewDidLoad {
In each case statement, as well as the ending braces after it.
Your code only defines the inner function in the function, and doesn't call it.
精彩评论