Sto tentando di inviare alcuni dati utilizzando NSNotification ma restiamo bloccati. Ecco il mio codice:Come passare userInfo in 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];
Ora, come per andare a prendere questo dizionario userInfo nel mio selettore orientationChanged?
Ok. E come si fa? È come: [[NSNotificationCenter defaultCenter] addObserver: self-selector: @selector (orientationChanged: self) nome: @ oggetto "Abhinav": nil] ;? – Abhinav
[[NSNotificationCenter defaultCenter] addObserver: self-selector: @selector (orientationChanged :) name: @ "Abhinav" object: nil]; – JustSid
Qualche motivo per cui si potrebbe finire con un dizionario nil? –