views:

29

answers:

1

Hi guys,

I have an NSURL which contains a URL and a variable that is an NSDate:

NSURL *url = [[[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://www.googlebio.com/xml_test.aspx?date=%@",self.storeDate]] autorelease];

I also tried it this way but to no avail:

NSString*string = [NSString stringWithFormat:@"http://www.googlebio.com/xml_test.aspx?date=%@",self.storeDate];

    NSURL*url=[NSURL URLWithString:string];
    [url autorelease];

The application does not crash but when I debug it, url is nil.

Any ideas as to why this is?

Thanks.

Stefan.

+2  A: 

If your date is in a format that NSURL will be confused by, then it will be nil. Make sure you urlencode your date, or represent it in a way that is a legitimate URL. Look into this:

[string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]

Perhaps if you put a debug statement of your url string, I can help further

coneybeare