Egor
Egor

Reputation: 1

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. While running programm don't creates variables (current, previous). Where is it call init-method in xCode?

Upvotes: 0

Views: 253

Answers (1)

Matthias Bauch
Matthias Bauch

Reputation: 90117

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];
}

Upvotes: 2

Related Questions