UIViewController remaining
Posted
by Guy
on Stack Overflow
See other posts from Stack Overflow
or by Guy
Published on 2010-04-13T20:49:14Z
Indexed on
2010/04/13
20:53 UTC
Read the original article
Hit count: 352
objective-c
Hi Guys. I have a UIViewController named equationVC who's user interface is being programmatically created from another NSObject class called equationCon. Upon loading equationVC, a method called chooseInterface is called from the equationCon class. I have a global variable (globalVar) that points to a user defined string. chooseInterface finds a method in the equationCon class that matches the string globalVar points to. In this case, let's say that globalVar points to a string that is called "methodThatMatches." In methodThatMatches, another view controller needs to show the results of what methodThatMatches did. methodThatMatches creates a new equationVC that calls upon methodThatMatches2. As a test, each method changes the color of the background. When the application starts up, I get a purple background, but as soon as I hit backwards I get another purple screen, which should be yellow. I do not think that I am release the view properly. Can anyone help?
-(void)chooseInterface {
NSString* equationTemp = [globalVar stringByReplacingOccurrencesOfString:@" " withString:@""];
equationTemp = [equationTemp stringByReplacingOccurrencesOfString:@"'" withString:@""];
SEL equationName = NSSelectorFromString(equationTemp);
NSLog(@"selector! %@",NSStringFromSelector(equationName));
if([self respondsToSelector:equationName]){
[self performSelector:equationName];
}
}
-(void)methodThatMatches{
self.equationVC.view.backgroundColor = [UIColor yellowColor];
[setGlobalVar:@"methodThatMatches2"];
EquationVC* temp = [[EquationVC alloc] init];
[[self.equationVC navigationController] pushViewController:temp animated:YES ];
[temp release];
}
-(void)methodThatmatches2{
self.equationVC.view.backgroundColor = [UIColor purpleColor];
}
© Stack Overflow or respective owner