tags:

views:

65

answers:

1

hi...

I am developing an applictaion in which i am doing xml parsing i found an error in [xmlparse parse] method. and the error for this is as follows: [NSCFString bytes]: unrecognized selector sent to instance 0x3df6310 2010-04-30 00:09:46.302 SPCiphone2[4234:1003] void SendDelegateMessage(NSInvocation*): delegate () failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

code snippet for this as follows.

responseOfWebResultData = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"result: %@", responseOfWebResultData); //starting the XML parsing

                                    if(responseOfWebResultData)
                                    {
                                        @try
                                        {
                                        xmlParser = [[NSXMLParser alloc] initWithData:responseOfWebResultData];
                                        [xmlParser setDelegate: self];
                                        [xmlParser setShouldResolveExternalEntities: YES];
                                        [xmlParser parse];
                                        [responseOfWebResultData release];
                                        }
                                        @catch(NSException *e)
                                        {
                                            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please " message:[e reason] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
                                            [alert show];
                                            [alert release];
                                        }
                                    }
+2  A: 

You should not be passing in a NSString* into initWithData:. You should do this:

xmlParser = [[NSXMLParser alloc] initWithData:responseData];

The error says that you're sending the message bytes to an instance of NSCFString, which is a NSString*, even though you declared it as a NSMutableString*, because this is a dynamically typed language but the class types are not automatically converted if you try to cast it to something else.

lucius
@lucius,you means the XMLParser should want only byte code data right?
RRB
I think so. When the method name is "initWithData:" you should pass in a NSData instance and not a NSString.
lucius
@lucius, ok great.If we commentsresponseOfWebResultData = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"result: %@", responseOfWebResultData); both lines so there not been aftecing to other code.
RRB