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

saleh.hi.62

macrumors member
Original poster
Jul 25, 2011
95
0
How to detect if it is a Web URL or a path?

in NSUrl Apple reference page has written, it accept a URL if it is based on standard, but any kind of string it accept as a URL, like this code:

Code:
NSURL *url=[NSURL URLWithString:@"/book.xml"];

    NSLog(@"%@",url);

This is not a web URL but it hold it and also return it as its value.

My concern is detecting URLs among other paths!
 
You could check the URL's scheme and if it's http or https it's not a file path. Or use -[NSURL isFileURL] and -[NSFileManager fileExistsAtPath:]
 
How to detect if it is a Web URL or a path?

in NSUrl Apple reference page has written, it accept a URL if it is based on standard, but any kind of string it accept as a URL, like this code:

Code:
NSURL *url=[NSURL URLWithString:@"/book.xml"];

    NSLog(@"%@",url);

This is not a web URL but it hold it and also return it as its value.

My concern is detecting URLs among other paths!

You are doing it again. You are asking stupid questions - stupid because you leave out what you are actually trying to achieve. Apart from that, the documentation of NSURL, if you could be bothered to read it, tells you exactly what method to use.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.