Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

satyam90

macrumors regular
Original poster
Jul 30, 2007
242
0
Bangalore, India
I am using
NSURL *url = [[NSURL alloc] URLWithString:[[NSBundle mainBundle] bundlePath]];
to convert the path to NSURL.
But url is null after the statement of execution. Can anyone tell me how to do this?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
I would use

Code:
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];

Note the url returned will be autoreleased: you might want to retain it...
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I am using
NSURL *url = [[NSURL alloc] URLWithString:[[NSBundle mainBundle] bundlePath]];
to convert the path to NSURL.
But url is null after the statement of execution. Can anyone tell me how to do this?

URLWithString: takes a string representation of a URL. bundlePath returns a path, not a URL, that is why you have to use fileURLWithPath.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.