November 2011
Beginner
238 pages
6h 19m
English
Beginning with iOS 4.0, iOS devices gained the ability for multiple apps to run simultaneously on a device. This can create some complex behavioral bugs when dealing with state, especially if the user is accessing two different Game Center–enabled apps at the same time. For example, the user may log out of Game Center, or even log in as a different user, while your app is in the background. Therefore, it is vital that you listen for changes to the local user through the NSNotification system.
Add the following snippet of code in viewDidLoad of UFOViewController.m, right after the test is performed to verify whether Game Center is available.
[[NSNotificationCenter defaultCenter] addObserver:self ...