iPhone NSNotification

1,783 views

Published on

SlideShareとkeynoteの練習を兼ねて。iPhoneアプリで使える、NSNotificationという通知の仕組みについての概要です。

Published in: Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,783
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • iPhone NSNotification

    1. 1. NSNotification
    2. 2. • NSNotification • • • • •
    3. 3. • NSNotification • NSNotificationCenter • • / MyObjB NSNotification MyObjA NSNotificationCenter MySendObj MyObjC
    4. 4. • • • MyObjB “Hoge” “Hoge” MyObjA NSNotificationCenter MySendObj MyObjC ”foo”
    5. 5. • NSNotificationCenter • / • ” ” • • NSNotification userInfo(NSDictionary) release MyObjB MyObjA NSNotificationCenter MySendObj MyObjC
    6. 6. • • • •
    7. 7. MyObjB ”hoge” popupAlert [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popupAlert:) name:@”hoge” object:nil]; MyObjB addObserver NSNotificationCenter
    8. 8. MySendObj ”hoge” // NSNotification NSNotification* notification = [NSNotification notificationWithName: @”hoge” object:self userInfo:nil]; // [[NSNotificationCenter defaultCenter] postNotification:notification]; “Hoge” NSNotificationCenter MySendObj postNotification
    9. 9. NSNotificationCenter MyObjB popupAlert -(void)popupAlert:(NSNotification *)notification { // UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sample" message:@” ” delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; } MyObjB “Hoge” NSNotificationCenter
    10. 10. removeObserver - (void)dealloc { // Notification [[NSNotificationCenter defaultCenter] removeObserver:self]; } MyObjB removeObserver NSNotificationCenter

    ×