applicationDidBecomeActive (Xcode) Better way?

Started by
6 comments, last by Erik Rufelt 9 years, 1 month ago

I am trying to call an action to keep my app from going idle like this: https://dl.dropboxusercontent.com/u/4047131/MyPublic/SetIdle.png

This works, but only after the user have first entered the app, then left to the homescreen and then re-enter it.

Is there some other place I can put it so it is activated without having to leave and come back to the app first?

Advertisement
applicationdidlaunchwithoptions ?
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

I can't access dropbox from work. Can you describe a little more what you are after.

applicationDidBecomeActive is the place to put your code.


This works, but only after the user have first entered the app, then left to the homescreen and then re-enter it.

That sounds strange... applicationDidBecomeActive should be called also when the application is first launched.

applicationDidBecomeActive is the place to put your code.


This works, but only after the user have first entered the app, then left to the homescreen and then re-enter it.

That sounds strange... applicationDidBecomeActive should be called also when the application is first launched.

I also thought this, but it does not. I have tried to use it with other things and it only triggers when going back to the app, not when it is first launched..


I also thought this, but it does not. I have tried to use it with other things and it only triggers when going back to the app, not when it is first launched..

I would guess your code in applicationDidBecomeActive relies on something being set up that isn't set up yet on first launch. Put a breakpoint there on launch or log the values/contents of relevant variables.

What do you mean by breakpoint?

Click the left column in the source-window in Xcode, at the line-numbers, on a line of code in applicationDidBecomeActive. It will create a blue mark there.

Then click the Run button to run your app, and when execution reaches applicationDidBecomeActive, your app will pause and you can check variable-values etc. in Xcode.

This is perhaps the one most important thing to learn in programming, so if you haven't done this before I would recommend spending some time with it.

This topic is closed to new replies.

Advertisement