Skip to Main Content
Professional iPhone® and iPad™ Application Development
book

Professional iPhone® and iPad™ Application Development

by Gene Backlin
November 2010
Intermediate to advanced content levelIntermediate to advanced
600 pages
14h 21m
English
Wrox
Content preview from Professional iPhone® and iPad™ Application Development

Chapter 6. Notification Processing

WHAT'S IN THIS CHAPTER?

  • Working with notifications

  • How to register to receive notifications

  • The NSNotificationCenter object

  • How to implement a local notification

iOS 4, like any other GUI environment, reflects an infinite series of events. Touches, swipes, connecting to a network, and the keyboard appearing are just a few examples of events. Notifications are broadcast when these events occur. An application registers to receive these notifications, in order to act when the event occurs.

The actual notification is encapsulated in an NSNotification object that will be broadcast. The NSNotification is then broadcast to the NSNotificationCenter. The application that wants to receive the notifications must register with the NSNotificationCenter in order to receive the notifications by adding themselves as an observer:.

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(keyboardDidHide:)
               name:UIKeyboardDidHideNotification object:nil];

To find out what notifications are sent by a particular class, look in the documentation for the class; the notification will be listed in the Notifications section. For example, the UIWindow class reference lists:

  • UIWindowDidBecomeVisibleNotification

  • UIWindowDidBecomeHiddenNotification

  • UIWindowDidBecomeKeyNotification

  • UIWindowDidResignKeyNotification

  • UIKeyboardWillShowNotification

  • UIKeyboardDidShowNotification

  • UIKeyboardWillHideNotification

  • UIKeyboardDidHideNotification

Use ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Visual Studio® 2010

Professional Visual Studio® 2010

Nick Randolph, David Gardner, Michael Minutillo, Chris Anderson
Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo, John Arkontaky, Yat Siu
Navigating the Metaverse

Navigating the Metaverse

Cathy Hackl, Dirk Lueth, Tommaso Di Bartolo

Publisher Resources

ISBN: 9780470878194Purchase book