According to the NSNotificationCenter
class reference:
Be sure to invoke removeObserver: or removeObserver:name:object: before notificationObserver or any object specified in addObserver:selector:name:object: is deallocated.
So: you should unregister your observer before self.playerItem
deallocated.
But when the user starts playing a different item, the old self.playerItem will be deallocated---but will always be replaced with a new one, which I want to continue observing.
You may pass nil
as the last parameter of addObserver:selector:name:object:
method:
Adds an entry to the receiver’s dispatch table with an observer, a notification selector and optional criteria: notification name and sender. If you don't specify
If you pass nil, the notification center doesn’t use a notification’s sender to decide whether to deliver it to the observer.
So you will receive notification AVPlayerItemDidPlayToEndTimeNotification
from any object that posts it.