Passing playerLayer to Notifications

In objective C, how would I pass a playerLayer to an NSNotification observer? Do I need to use NSDictionary?

Replies

I do not know if you can use playerLayer as the [noticiaftion object] or whether you would need to wrap it in an NSArray:


Use:


       NSArray *anArray=[NSArray arrayWithObject:playerLayer];
       [[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:anArray];
                   
          //or
                    
       [[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:playerLayer];


// then elsewhere:


       [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(processNotification:)
                                                 name:@"MyNotification" object:nil];


//and

-(void)processNotification:(NSNotification *)notification{
       //    then handle either [[notification object] objectAtIndex:0]
       //                  or    [notification object]
       //   as your playerLayer

}