iOS - how to call applicationDidFinishLaunching or didFinishlaunchingWithOptions

I’ve been able to use viewDidLoad successfully in my view controllers, but I’d like to move some code from viewDidLoad to applicationDidFinishLaunching or application: didFinishlaunchingWithOptions. Would this have to be in the testApp file? And if so, how would either of these be called?

thanks

rh

Hi,

Have you checked out the iosNativeExample project in the OF examples folder?

That uses MyAppDelegate.mm with a didFinishLaunchingWithOptions already.

But that example bypasses testApp. I’m using testApp and don’t see how I would integrate the appDelegate method with testApp.

Hi,

I don’t have the code in front of me right now, but as far as I remember it doesn’t bypass testApp, it just allows you to specify multiple testApps which get created and deleted from the main iOS application. So either you could look at modifying that example to automatically go through to starting your own testApp. The other alternative I see is to start looking into the OF lib (ofxiPhone?) code and finding the original applicationDidFinishLaunching call inside there… basically making a custom change in the lib for your own purposes.

It says in the iosNativeExample: "//NOTE: in this example testApp ( this class ) is not used. "

Instead it uses the app delegate to create a root view controller. It’s not clear to me how testApp could be plugged into such an approach. Looking briefly at ofxiPhone, it seems to use a similar approach and does not use testApp.

*That* testApp isn’t used, but if you navigate to the Apps folder there are four testApps (called CircleApp, ImageApp, etc) which are the same format as testApp.

In the UI folder there’s an iOS app delegate which gets called where maybe you could add your changes there…

Otherwise, for the other approach, maybe hack a bit with ofxiPhoneAppDelegate.mm in the OF lib itself.

I did have a go at working with the original call to applicationDidFinishLaunching in ofxiPhoneAppDelegate, but I needed to use ofxiPhoneAppDelegate as a delegate of one of my view controllers in order to call a function from that view controller, and I couldn’t figure out how to do that. I’ll have a look at the other testApps you mention. Thanks.

I should mention that what I’m trying to do is to fade out a CALayer that I’ve added as a sublayer to one of my view controllers. At present I’m doing this from viewDidLoad, but a more ideal approach would be for me to call that fading out function from applicationDidFinishLaunchingWithOptions (so that the layer doesn’t reappear every time the user goes back to the app). If someone can tell me how to make that call from the ofxiPhoneAppDelegate back to my custom view controller, that would do the trick.