tags:

views:

20

answers:

1

Error I am getting:

*[NSURLError object]: unrecognized selector sent to instance 0x5f510e0 *
2010-10-11 11:41:33.718 CBH[15454:207] ** Terminating app due to uncaught exception *'NSInvalidArgumentException', reason: '-[NSURLError object]: unrecognized selector sent to instance 0x5f510e0' *

here is the code:

 NSArray *args = [NSArray arrayWithObjects:@"username",@"password",nil];   // the param(s)

    NSString *server = @"https://username:password@webservices.****.***:443/dsa/xmlrpc/restricted1/";         // the server 

    XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithHost:[NSURL URLWithString:server]];
    [request setMethod:@"BootService.getPublicTokenGeneric" withObject:args];

    id response = [self executeXMLRPCRequest:request];
    [request release];

    if( [response isKindOfClass:[NSError class]] ) {
        NSLog(@"Error : %@",response);

    }
    else {
        NSLog(@"Response ");
    } 

 }

- (id)executeXMLRPCRequest:(XMLRPCRequest *)req {
    NSLog(@"HEllo"); 
     XMLRPCResponse *userInfoResponse = [XMLRPCConnection       sendSynchronousXMLRPCRequest:req]; 

    if([userInfoResponse isKindOfClass:[NSError class]]) {
        NSLog(@"Error %@",userInfoResponse);

    }       
    return [userInfoResponse object];
}     

Could some one help me tearing out this error!!

I edited the code and now I can see NSURLError is: Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
NSErrorFailingURLStringKey=http://username:password@..org:443/zws/xmlrpc/restricted1/, NSErrorFailingURLKey=http://username:password@..org:443/zws/xmlrpc/restricted1/,
NSLocalizedDescription=The network connection was lost., NSUnderlyingError=0x5f2b300 "The network connection was lost.

A: 

Looks like XMLRPCConnection is giving you back an NSURLError object which does not like the object selector you are calling.

So userInfoResponse IS an NSURLError. You will need to test for this just like you are testing for NSError, although sooner.

XMLRPCResponse *userInfoResponse = [XMLRPCConnection sendSynchronousXMLRPCRequest:req];
if([userInfoResponse isKindOfClass:[NSURLError class]]) {
    //Do something else
}
else return [userInfoResponse object];

Your id based code is prone to these kind of errors, I suggest more strongly typed methods.

Ben
I have added the code and edited in question, I can see what error userInforesponse is, please go through it and see you can figure out problem, Thanks.
Akki