views:

682

answers:

1

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

+1  A: 

Have you tried:

NSString *theXML = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding];

This should cut out several calls to worry about before we dig into which one might be causing the trouble.

Rob Napier
yes i tried but unfourtunately it didnt work either :(
xenep
If the above does not work, you need to check what you're getting in webData. Debug your code and make sure it is initialized properly. If it is indeed an NSData, the initWithData should work
lostInTransit
Agreed. The #1 cause for "nothing happens" is that something is nil. In this case, the most likely thing to be nil is webData. If webData is not nil, and initWithData:encoding: returns nil, then that means that webData is not actually UTF8. Take a look at the bytes and make sure that it's what you think it is. For instance, perhaps there is binary or compressed data in there. Perhaps it is encoded UTF16. If any part of the data is not UTF8, then initWithData:encoding will fail.
Rob Napier