View Full Version : NSString initWithBytes isNotEqualTo error

May 4, 2009, 09:11 AM
Hi all,

i am using soap request in my application and using initWithBytes to convert the retrieved NSMutableData to NSString.

NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];

while i am running the app on the simulator everything works fine. but at the iPhone above code quits with the error :

'NSInvalidArgumentException', reason: '*** -[NSCFString isNotEqualTo:]: unrecognized selector sent to instance 0x16b7e0'

there is no code that includes 'isNotEqualTo' and the problem does not occure at every request.

Thanks in advance

May 4, 2009, 09:19 AM
Looks like the problem might be elsewhere if you're not calling that method in your code.

BTW, if you're converting an NSData object to an NSString it's probably better to use initWithData:encoding: since you're using the entire data object.

May 4, 2009, 09:23 AM
thanx for ur reply but i ve already used 'initWithData:encoding:' and it has the same result :(

May 4, 2009, 09:25 AM
Set up a gdbinit file as described in this thread


That will help you to see the backtrace where the problem is occurring.

Is it possible that your webData object hasn't been retained correctly?

May 4, 2009, 09:44 AM
Is it possible that your webData object hasn't been retained correctly?

it should be correct cause it does not ve any problem at simulator.

Set up a gdbinit file as described in this thread


i read the thread but i couldnt figure out how to create a gdbinit file. i created a text edit and changed the extension but it was still a text edit, also looked at xCode File->new file but couldnt find a file type that has a . gdbinit extension.

May 4, 2009, 10:58 AM
You can also add a symbolic breakpoint which has the same effect as the gdbinit file but only for your current project as opposed to every project (you are better off setting up the gdbinit file if the truth be told but this is a quick way). In Xcode go to Run->Manage Breakpoints->Add Symbolic Breakpoint and type in objc_exception_throw into the textbox. Now when you run your app and it crashes out throwing an exception you will be able to open up the debugger window and look through the stack to find your problem

May 4, 2009, 01:58 PM
Create a text file with the contents shown in that thread and called ~/gdbinit Once the file exists go to the Terminal and enter this command

mv gdbinit .gdbinit

Or use TextWrangler, which will open hidden files.