How to catch this exception: NSInvalidArgumentException

Discussion in 'iOS Programming' started by freakmoister, Dec 2, 2011.

  1. freakmoister macrumors newbie

    Dec 2, 2011
    Hi Everyone

    I'm trying to implement a http connection delegate but I keep running into this error:

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

    It happens when it calls the line starting with "NSURLConnection alloc...."

    Can anyone give me a pointer as to what I'm missing?

    I call this method from another class with the following lines:

        NSLog(@"Initing conn....");
        conn = [[httpConn alloc]init]; // conn has property in header --> @property (nonatomic, retain) httpConn *conn;
        NSLog(@"requesting reqURL....");
        [conn load:reqURL];

    Here's how I implemented the "load" method...

    #import "httpConn.h"
    @implementation httpConn
    @synthesize responseData;
    // code omitted....
    - (void)load:(NSString *)myURL
        [responseData release];
        responseRCVed = NO;
        NSLog(@"url received: %@",myURL);
        NSURLRequest *request = [[NSURLRequest requestWithURL:[NSURL URLWithString:myURL]
                                             timeoutInterval:60] retain];
        if (request) {
            NSLog(@"request is not nil");
            // ---> throws exception when calling the following line
            [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
        [request release];
    // code omitted...
  2. takeshi74 macrumors 601

    Feb 9, 2011
    Should be posted in a development forum if you really want answers. This will just get buried due to the traffic in here.

Share This Page