[NSPathStore2 finishedPlaying]: unrecognized selector sent to instance
Intermittently while running my program it crashes out with:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPathStore2 finishedPlaying]: unrecognized selector sent to instance 0x286e20'
According to the internet there is zero documentation available on this function so I turn to you illustrious Stack Overflow.
It somewhat seems to coincide with the loading/playing of sounds using the CocosDenshion library. I can't be sure exactly where (if it is) because it never seems to happen while I am stepping through.
This is while testing on a 1st Gen iPod Touch with 3.1.3 installed. The program works flawlessly on devices with iOS 3.2 and above.
Sorry to bump this old topic, but I have been struggling with the same issue for a couple weeks and wanted to share my experience.
A small percentage of my users are getting fatal exceptions of the format: "[__NSCFNumber finishedPlaying:]: unrecognized selector sent to instance 0x1fa8ed40" It seems to be limited to iOS 6 devices, but it has been impossible to debug since I can't reproduce it myself.
I believe the two other answers are barking up the wrong tree. Both suggest that the problem is related the AVAudioPlayer delegate, which is the problem discussed in The reason behind crash in AVAudioPlayer finishedPlaying after upgrade to iPhone 3.0 OS. But you'll notice that in this case the finishedPlaying method is successfully called and the exception there is related to the audioPlayerDidFinishPlaying: method.
In this problem it is the finishedPlaying: selector that is not recognized, meaning that it is the AVAudioPlayer itself who is no longer valid, rather that its delegate.
Upon this realization I now think that the problem is a result of the AVAudioPlayer being incorrectly managed (I was using a non-ARC helper class: NTAVManager). I've updated the class to use ARC and hope this will fix my problem, but as I said I have never been able to reproduce it myself so I won't be able to confirm for a few weeks.
The solution that worked for me is:
AVAudioPlayer_Instance.delegate = nil;
AVAudioPlayer_Instance
is your instance of AVAudioPlayer
and this should be called before dealloc
.
Take a look at this: The reason behind crash in AVAudioPlayer finishedPlaying after upgrade to iPhone 3.0 OS
I suspect that the reference to the AVAudioPlayer delegate is no longer valid, and the message is being sent to the address of a different object (NSPathStore2 in your case).
精彩评论