Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: -[UIImage _deleteExternalReferenceFromPermanentLocation] unrecognized selector sent to instance

When I delete a managed object that contains image, stored as transformable value in external record, then I got crash and this error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage _deleteExternalReferenceFromPermanentLocation]: unrecognized selector sent to instance 0xde49360' 
like image 598
Shmidt Avatar asked Oct 28 '11 14:10

Shmidt


2 Answers

I answered to something similar in the Apple Developer forums.
I am guessing you have the external storage checkbox selected on that field in the data modeller.

There is a bug in that can be worked around. I did it like this:
Once you have updated your data, and saved the context, any attempt to delete it will raise this 'unrecognized selector' exception.
To force the correct object that can respond to the _deleteExternalReferenceFromPermanentLocation message, do this:

[[self managedObjectContext] refreshObject:myobject mergeChanges:NO];

The object turns into a fault. When you next access it, or delete it, the external data is deleted as expected as the correct object that wraps your external data will be pulled from the store and will correctly respond to _deleteExternalReferenceFromPermanentLocation.

like image 95
emp Avatar answered Nov 04 '22 01:11

emp


The means that UIImage does not respond to the:

_deleteExternalReferenceFromPermanentLocation

…selector which means that UIImage doesn't implement that particular method. This appears to be one of the private methods that Core Data uses to store large chunks of data in external files. That's a function only available in iOS 5.

In this case there are two most likely causes:

(1) You've confused a UIImage object with a managed object or vice versa such that a message intended for one class is sent to another (that is the most common cause of this class of error.)

(2) You trying to run code compiled for iOS 5 under an earlier iOS either in the simulator or the device.

like image 34
TechZen Avatar answered Nov 04 '22 00:11

TechZen