Estoy tratando de enviar algunos datos usando NSNotification pero me atoco. Aquí está mi código:¿Cómo pasar userInfo en NSNotification?
// Posting Notification
NSDictionary *orientationData;
if(iFromInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
orientationData = [NSDictionary dictionaryWithObject:@"Right"
forKey:@"Orientation"];
}
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter postNotificationName:@"Abhinav"
object:nil
userInfo:orientationData];
// Adding observer
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged)
name:@"Abhinav"
object:nil];
Ahora, ¿cómo se ha podido recuperar este diccionario userInfo en mi selector de orientationChanged?
Ok. ¿Y cómo hacer esto? ¿Es como: [[NSNotificationCenter defaultCenter] addObserver: auto selector: @selector (orientationChanged: self) name: @ "Abhinav" object: nil] ;? – Abhinav
[[NSNotificationCenter defaultCenter] addObserver: selector automático: @selector (orientationChanged :) name: @ "Abhinav" object: nil]; – JustSid
¿Alguna razón por la cual uno puede estar terminando con un diccionario nulo? –