Search code examples
objective-cerror-handlingwarningsuncaught-exception

Why do I get this Warning/Error?


I have placed together some code which converts strings into data, and then places the data into another textfield. Everything works fine, but when I run the program and tap the button with the IB Action that contains this code:

[InputData setStringValue:OutputString];

I get this error:

Thread 1: Program Received Signal: "SIGABRT".

And in the Output area in the bottom of Xcode I get this message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData setStringValue:]: unrecognized selector sent to instance 0x62507e0'

Why does this happen? The warning tells me that:

Instance method -setStringValue' not found (return type defaults to id)

What is going on, I have looked over it and it seems like it should work. What am I doing wrong? Im only a beginner with Objective-C.

Thank you, anything is appreciated.


Solution

  • Sounds like there is a category on NSData that includes a setStringValue method. The category implementation file is likely named something like NSData-extras.m. Ensure that file has been added to Xcode (and if already known to Xcode, is part of the Target being built).