problem with method init of view controller class
I try to run programm (http://www.edumobile.org/iphone/iphone-programming-tutorials/calculator-application-in-iphone/) from here, but i have problem with init method. W开发者_如何学JAVAhile running programm don't creates variables (current, previous). Where is it call init-method in xCode?
the init method is never called because the ViewController is loaded from a nib file.
You could move those 3 lines into viewDidLoad
. But to be honest, I think it's better when you trash the project and look for something better. Because this is not the only problem of the project.
If you learn with these "tutorials" you will have huge problems later.
That guy has obviously never heard about memory management.
But if you want to try, add this method to the @implementation
of calciViewController
- (void)viewDidLoad {
[super viewDidLoad];
operator=0;
current =[[NSString stringWithString:@"0"]retain];
previous =[[NSString stringWithString:@"0"]retain];
}
精彩评论