1

I am trying to show a HTML String in uiwebview and it give me the error below:

 **-[__NSArrayI dataUsingEncoding:]: unrecognized selector sent to instance 0x75caf40
2013-09-17 10:26:48.774 iphoneApp[9395:2903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI dataUsingEncoding:]: unrecognized selector sent to instance 0x75caf40'
*** First throw call stack:
(0x1cca012 0x1107e7e 0x1d554bd 0x1cb9bbc 0x1cb994e 0x26fc8ea 0x26fc97a 0x2027fa 0x35a2548 0x1c4df3f 0x1c4da39 0x1c70734 0x1c6ff44 0x1c6fe1b 0x35a1c50 0x9628f5b7 0x96279d4e)
libc++abi.dylib: terminate called throwing an exception*
*emphasized text**

here is the code:

NSString *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSString *desc = [json valueForKey:@"description"];
NSLog(@"%@",desc);
[self.jobdescription loadHTMLString:desc baseURL:nil];

if I copy the output string from NSLog and put it in loadHTMLString its fine but if I put "desc" which is the same I will get the error. I have not idea what could have gone wrong. Thanks

4

2 回答 2

1

Try the following statement.

[self.jobdescription loadHTMLString:[NSString stringWithFormat:@"%@",desc] baseURL:nil];

And please check whether the "self.jobdescription" is a UIWebView object or not.

于 2013-09-17T15:56:15.370 回答
0

Seems like desc is not string but array. Add NSLog(@"%@", NSStringFromClass([desc class])); to ensure.

于 2013-09-17T15:59:22.353 回答