When I try to play a video from my iPhone (located in the documentsDirectory), I get the following error using iOS 5 while it was working fine with iOS 4.3:
An insta
I have had the same error before and simply remove the observer when the view goes away will clear leak.
Put
[[NSNotificationCenter defaultCenter] removeObserver:self];
in willWillDisappear
or dealloc
Ah. You're observing a TekkPoint object from a SomethingElse object, and the SomethingElse object is the one adding and removing the observers, correct? (That's the normal way things are done; I'm just trying to clarify.)
It looks like your TekkPoint object is being deallocated while the SomethingElse that's observing it is still around. The SomethingElse dealloc method isn't called because it's the TekkPoint that's being deallocated, not the SomethingElse.
If you're planning on observing an object which may disappear before the observer disappears, then you need some way of notifying the observers that they should remove their observers. Your TekkPoint could have an alive property which would also be observed by the SomethingElse, and when it gets set to NO then everyone observing the TekkPoint would remove themself as an observer.
EDIT: Just after posting the answer below I noticed that whenever the controller was reallocated, the errors came back as the old controller got automatically deallocated, even if I set up absolutely no notification handlers myself. Since the failures are coming from code inside the MP framework, I would say that this seems to be an OS bug.
I encountered the same issue with a storyboard-based iOS 5 project using ARC. The problem is the use of a temporary variable on the stack to refer to the movie controller - in my case I assumed an interaction with ARC, but it may be more fundamental than that. In any event, it looks as if something gets deallocated/lost too early (e.g. when a playback error occurs) and the log gets filled with the sort of output you describe.
Storing the movie controller reference in a property defined within the owning class solved this in my case; i.e:
@interface MyClass
@property ( strong, nonatomic ) MPMoviePlayerViewController * movieController;
@end
@@implementation MyClass
@synthesize movieController = _movieController;
// ...then later, this:
//
// MPMoviePlayerController *moviePlayerController = [...];
//
// ...becomes:
self.movieController = [...];
If you're using synthesised accessors for the property then whether you're using manual or automatic reference counting the generated setter method should correctly deallocate the old movie controller (if there is one) before setting up the new one.
As a footnote, if you (say) dealloc/'unreference' (set-to-nil) the property manually in a MPMoviePlayerPlaybackDidFinishNotification
notification handler then you'll probably notice that the errors come back. So don't do that :-)