24 Jun 2017

PostNotification & Observer...


PostNotification & Observer...


@interface AppProperties : NSObject
#define NotificationNameDropBoxDeclined  @"DropbBoxAccessDeclined"
@end



  NSNotification *myNotification = [NSNotification notificationWithName:NotificationNameDropBoxDeclined
              object:self //object is usually the object posting the notification
            userInfo:nil]; //userInfo is an optional dictionary if you want to pass something you can..
                
   //Post it to the default notification center

 [[NSNotificationCenter defaultCenter] postNotification:myNotification];


This should excute First means before postNotification & mostly observer in viewDidload method...

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(declinedDropBoxAccess:)
                                             name:NotificationNameDropBoxDeclined

                                           object:nil];

-(void)declinedDropBoxAccess:(NSNotification *)notification
{
 // write want you want to excute...
}

No comments:

Post a Comment

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0