If you are here, you probably got a NSInvalidArgumentException. Below is what I got, and even if your one is not the same, hopefully the explanation will help you solve yours:
Here is why this came all the way up:
- My application uses a documentInteractionController
- My application uses a documentInteractionController
- It resides in a class
- Helps to figure out 3rd party applications on my iOS device I can use to open certain files from my application
- once it does and I go back to my application... bang ! my app exists, mugshot of the culprit is above
This is because the documentInteractionController fires callbacks, and unfortunately in my application the class was released and no longer available. Since the class is no where to be found, the OS cannot call the callback methods and we get the above error. (callbacks are methods that fire after certain events, in this case the method "didEndSendingToApplication" fires to let us know that the 3rd party application got my file)
-To rectify:
- I had to retain the documentInteractionController (and also the parent view due to some specifics of my application)
- Release it after the callbacks were fired.
Read a bit on memory management in iOS and ARC (automatic reference counting)
Memory management: https://developer.apple.com/library/ios/documentation/general/conceptual/devpedia-cocoacore/MemoryManagement.html
You basically the 'retain' keyword to keep your objects around and then 'release' it after you are done.
Make sure you cover all paths if you do so, you are interfering with the memory management, so cover your tracks well and avoid memory leaks. Even though you might not see any visible side effects, we should always write quality code :)
Hope this helps someone :)