0

I'm getting an abort under very limited circumstances and I'm trying to find out what statement or statements is causing it. The console says:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSPathStore2 setDelegate:]: unrecognized selector sent to instance 0x1d50dcb0'

NSPathStore2 doesn't appear anywhere in my code so that must be called by some framework I'm using. The instance address doesn't appear anywhere else so I can't tell what that is.

I tried using breakpoints to catch when the abort happens, but then it doesn't happen any more. So maybe it's a timing problem. I read in other posts that NSPathStore2 is part of NSString so I tried putting print statements around various string statements but that didn't help. Searching developer.apple.com for NSPathStore2 doesn't find anything.

I think the abort happens during an init method but that method is long and it calls other long methods before it's done. Also, it only happens after running through a 5-minute sequence of actions and only after a fresh install from Xcode. If I run the app a second time it doesn't abort. So it's very time consuming trying to find where this is coming from.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
RobertL
  • 14,214
  • 11
  • 38
  • 44
  • This is with Xcode 4.5, testing on an iPhone 4 with iOS 5.1.1. And I'm pretty sure there is plenty of memory for this app. – RobertL Oct 10 '12 at 22:53
  • Are you setting any delegate's that you're not sure about? – mkral Oct 10 '12 at 23:18
  • Usually, unrecognized selectors happen when you make an incorrect assumption about the class of an object, so logging string methods wouldn't help. You should look anywhere you set a delegate and log the class of the object you call that on. – ughoavgfhw Oct 10 '12 at 23:22
  • mkral and ughoavgfhw: Your comments led me to the answer. I was using accelerator.delegate = ... where accelerator was an ivar that was created a long time before and not retained. It had gone out of scope by the time that statement occurred. If you want to rewrite your comment as an answer I can give it a check. I retained accelerator and the abort went away (at least it didn't happen in 2 test runs. My fingers are crossed.) – RobertL Oct 11 '12 at 14:57

1 Answers1

1

This is a very common symptom that you have a deallocated object still being used somewhere. Check "Enable Zombie Objects" in your debug scheme and look for where you are calling a method on a deallocated object.

John Estropia
  • 17,460
  • 4
  • 46
  • 50
  • I don't think enabling zombies would have found it. I had already thought of a zombie but Zombies usually result in "EXEC_BAD_ACCESS" whereas this was an abort. But thanks for replying. Your idea was close. – RobertL Oct 11 '12 at 15:05
  • Do tell us what fixed your problem so we can use it for reference next time – John Estropia Jan 21 '13 at 02:49