Search code examples
memory-managementios8unrecognized-selector

Strange, sporadic CUI... NSInvalidArgumentException errors


My application (on iOS8) is infrequently crashing due to 'unrecognised selector' and 'deallocated instance' messages sent to classes that are not publicly accessible. These errors include:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[CUIRenditionKey type]: unrecognized selector sent to instance 
0x14d04270'

and

*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[CUIMutableThemeRendition exifOrientation]: message sent to
deallocated instance'

As I have no understanding of these classes (they also don't appear on any searches): how am I supposed to fix these error messages.

Are these bugs in iOS8?

(It may be related to this mac issue)


Solution

  • I had this same problem recently, and tracked it down to an erroneous assign property setting, when it should have been retain - a silly copy-paste error.

    So basically I had this line:

    @property (nonatomic, assign) id area;
    

    when it should have been:

    @property (nonatomic, retain) id area;
    

    The segue calling code set the value and then released the memory (thinking it was unused since it was not retained). So when the new UIView appeared the selector was sent to some other default value (in my case, the CUIRenditionKey just like yours).