how to fix: 'NSInvalidArgumentException', reason: 'data parameter is nil'

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

  1. freakmoister macrumors newbie

    Joined:
    Dec 2, 2011
    #1
    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:

    Code:
        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...

    Code:
    #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]
                                                 cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                             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. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    Can you post the stack trace of the exception?
     

Share This Page