Domanda

C'è un modo per rompere il NSNotificationCenter la pubblicazione di una nota con un certo nome? Ho una classe che per qualche motivo non ricevono It Nota previsto ...

Modifica di chiarimenti:

Ho aggiunto un osservatore per il MPMoviePlayerPlaybackDidFinishNotification, ma per qualche ragione sembra come se la notifica non viene inviato come previsto. Un guasto normale è che il mio oggetto per qualche ragione stessa ha annullato l'iscrizione in qualità di osservatore (anche se trovo il mio codice su quella parte di guardare valido). Quindi, la mia intenzione era se sia o non è possibile rompere il NSNotificationCenter in realtà passando su un NotificationName di un certo tipo, in questo caso MPMoviePlayerPlaybackDidFinishNotification ...

È stato utile?

Soluzione

Add a breakpoint in Xcode with the name "-[NSNotificationCenter postNotification:]" using the box displayed in the screenshot. Just remember that this will stop for every notification posted, so you might want to have the debugger log the arguments and autocontinue.

Altri suggerimenti

You can put break point in methods which you call for certain event. e.g.

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];

[nc addObserver:self selector:@selector(keyboardWillShow:) name: UIKeyboardWillShowNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillHide:) name: UIKeyboardWillHideNotification object:nil];

here you can use break point in keyboardWillShow and keyboardWillHide method which call on the time of keyboard events.

So you need to specify valid event name and valid object name.

In case of textfield as an object you use like this

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

[notificationCenter addObserver:self
                       selector:@selector (handle_TextFieldTextChanged:)
                           name:UITextFieldTextDidChangeNotification
                         object:self.lockTextField];

so i think you need to add notification in right way.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top