views:

311

answers:

1

I am loading some info from a server. I have created a separate method to do this. I am then calling [self myCustomMethod] to run the method. No matter where I call [self myCustomMethod] (initWithNibName, viewDidLoad, viewWillLoad, viewWillAppear, viewDidAppear), the custom method is getting called twice - what's the deal?

A: 

Are you sure you aren't instantiating your UIViewController twice? Or call any of these methods yourself at some point? initWithNibName will only be called once, the other methods may be called more than once in the life span of a UIViewController. This doesn't mean however that initWithNibName is the best place to call your method. It depends on exactly what it does, for example, wether it needs to do anything with the view.

Johan Kool