Something before didFinishLaunchingWithOptions

Is there any way to execute some code before the didFinishLaunchingWithOptions: method is called?

Upvotes: 3

Views: 2490

Answers (4)

aytunch
aytunch

Reputation: 1444

Addition to the friends answers/comments, I believe that the uistoryboard's initialviewcontroller's awakeFromNib runs before didFinishLaunchingWithOptions: too.

Upvotes: 0

Costique
Costique

Reputation: 23722

Implement your app delegate -init method and it will execute before application:didFinishLaunchingWithOptions:. Implement your app delegate class +initialize method to execute code even earlier (though you cannot access your app delegate instance there - it doesn't exist yet). As has already been said, you can also modify main().

There are a lot of options.

Upvotes: 10

Antonio MG
Antonio MG

Reputation: 20410

If you want to execute code after the XIB is loaded, go to the ViewController of that XIB and do whatever you want in:

- (void)viewDidLoad

For the first time you load the view, or

- (void)viewDidAppear:(BOOL)animated 

For every time you open the view

Upvotes: 1

detra83
detra83

Reputation: 739

What Joe said, or, if you'd be more specific in what you want to do, we might find a better solution.

Upvotes: 1

Related Questions