-2

How can I stop my game when I am on home or in the double click place, because my game continue and when I open it again I already lose.

2 Answers2

0

You need to add code to applicationWillResignActive: in your app delegate.

This question also has some discussion on this topic.

Community
  • 1
  • 1
Brett Donald
  • 3,491
  • 4
  • 20
  • 46
0

It's actually much better policy to sign up for UIApplicationWillResignActiveNotification.

NSNotificationCenter.defaultCenter().addObserverForName(UIApplicationWillResignActiveNotification, object: nil, queue: nil) { (notification:NSNotification) in
        self.pause()
    }

Otherwise you will need to get references to your UIApplicationMain, which is basically the wrong way to do things. This is what NSNotificationCenter was made for.

Daniel Kanaan
  • 1,063
  • 9
  • 19