Posts Tagged ‘Tutorial’

How-to: Prevent iPhone from Deep Sleeping

August 23rd, 2009

As I have promised three weeks ago (and again a few days ago) I finally got around to writing this little how-to.
I’m sorry for the delay. I hope this helps someone, anyway.

Mind you, this is my first attempt at writing a how-to, and most of it was done, while I was being tired. Also, English isn’t my native language, so please excuse any typos or other errors, you may find.

If you have any suggestions, how to improve this, please feel free to leave a comment.

Now, have fun!

Preface

We will create an iPhone application, that keeps the iPhone from deep sleeping, while it’s running. It’s not a really useful application, as it does nothing but just that, but you can easily adapt the stuff you learn here and use it for your own application(s).

Here’s exactly what we’re going to do:
We will …

  • … create a new project in Xcode.
  • … add the necessary frameworks to this project.
  • … add a silent sound file to this project.
  • … create a class called “DeepSleepPreventer” and add it to this project.
  • … then use this class to prevent the iPhone from deep sleeping.

You can use this class in your other apps, to prevent them from sleeping. Just add the needed frameworks and the DeepSleepPreventer class to your app and use the DeepSleepPreventer, whenever you need it.

» Read more: How-to: Prevent iPhone from Deep Sleeping