Questions tagged [nsurl]

NSURL is a class from Foundation.framework in Apple MacOS and iOS. The NSURL class provides the ability to manipulate URLs and the resources they refer to. An NSURL object represents a URL that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data. It is available in iOS 2.0 and later

The NSURL class provides a way to manipulate URLs and the resources they reference. NSURL objects understand URLs as specified in RFCs 1808, 1738, and 2732. The litmus test for conformance to RFC 1808 is as recommended in RFC 1808—whether the first two characters of resourceSpecifier are slashes (//).

An NSURL object is composed of two parts — a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object whose string is fully resolved without a base is considered absolute; all others are considered relative.

The NSURL class fails to create a new NSURL object if the path being passed is not well-formed; the path must comply with RFC 2396.

The NSURL class is toll-free bridged with its Core Foundation counterpart, CFURLRef.

Sample:

For example, when constructing an NSURL object, you might specify file:///path/to/web_root/ as the base URL and folder/file.html as the string part, as follows:

NSURL *baseURL = [NSURL URLWithString:@"file:///path/to/web_root/"];
NSURL *url = [NSURL URLWithString:@"folder/file.html" relativeToURL:baseURL];
NSURL *absURL = [url absoluteURL];
NSLog(@"absURL = %@", absURL);

Resource

1649 questions
0
votes
1 answer

How to bind NSURL in plist to NSPathControl in sandboxed app?

My OS X app needs persistent access to a directory the user chooses. Before I turned on app sandbox the UI had a NSPathControl with a value binding to the data model. The data type in the model is NSData and the binding used a…
0
votes
0 answers

stringByAddingPercentEscapesUsingEncoding error string

I'm sending a GET request and my url is http://myurl.com/addpla?name=JJ Burger &category=Delicatessen and Other &location=Sao jose do Rio Preto (I did use NSLog and it's correct) but after NSString *encodedURL = [url…
0
votes
2 answers

Why xcode and RestKit crash from NSURL nil string parameter

I am new to xcode and following this RestKit tutorial: https://github.com/RestKit/RKGist/blob/master/TUTORIAL.md I have gone through it once succesfully. I am going through it again and customizing it to fit my needs and for some reason, very early…
0
votes
2 answers

How to change parameter in URL iOS

I have a URL like myApp://action/1?parameter=2&secondparameter=3&thirdparameter=10 I need to change parameter = 2 and secondparameter =3 like myApp://action/1?parameter=10&secondparameter=15&thirdparameter=10 Any ideas Thx a lot
user2398911
  • 96
  • 1
  • 14
0
votes
1 answer

stringByAddingPercentEscapesUsingEncoding adds unexpected characters?

I'm having a hard time getting my NSURL to work, when I create the final string before converting to URL it adds unwanted character to the end of the string, why is this happening and how can I fix it? Here is my code: NSString *remotepathstring =…
Bogiematch
  • 27
  • 7
0
votes
2 answers

iPhone App Custom Url Scheme Issue

I am trying to get a custom url scheme to open a url inside the application. So the url scheme would be "example://confirm?1234" which I would like to use the query string as part of a url for a UIWebView. So that would make the UIWebView open…
Bob Stone
  • 39
  • 1
  • 5
0
votes
1 answer

Adding data given by the user to an array - Objective-C

I'm trying to create a Mac OS X app where there are some default sound and the user can add others if he wants. I'm loading the sounds to an array in -awakeFromNib : for (NSString *str in [PreferencesController beats]) { resourcePath =…
0
votes
1 answer

Convert Colon-Separated Path to NSURL

Is there a straight-forward way to convert a colon-separated path (i.e. "Macintosh HD:Users:stuarttevendale:Documents:DBTest.db") to an NSURL (i.e. "file://localhost/Users/stuarttevendale/Documents/DBTest.db")?
Stuart Tevendale
  • 614
  • 6
  • 19
0
votes
1 answer

Get block device from NSURL

The question says it all. How can I get the block device from an NSURL representing, for example, a removable media? What I would like to get from /Volumes/MyDevice is something like /dev/disk2. I wonder if that is possible without using the IOKit…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
0
votes
2 answers

xcode thrown error when logging NSURL

can anyone help solve this error when running xcode with the following code and trying to nslog url1 .m file NSLog(@"URL flag is not set, Reverting to stored value"); //url1 = [NSURL URLWithString: [NSString stringWithFormat:…
Ossama
  • 2,401
  • 7
  • 46
  • 83
0
votes
1 answer

Crash when trying to open downloaded pdf in new view

My app downloads a pdf and then on a button press brings it up in a new view. I get the error: -[NSURL initFileURLWithPath:]: nil string parameter' After some troubleshooting I pinned the problem to somewhere in this code snippet. The path that…
Bogiematch
  • 27
  • 7
0
votes
1 answer

Http Get request issue

I need to get the data from service URL. But I couldn't get it .May be something like whitespaces is preventing it .I couldn't understand how to resolve it. NSString *urlString=…
Nikhat Afshan
  • 65
  • 1
  • 1
  • 7
0
votes
2 answers

AFNetworking UIImage NSURL

I use AFNetworking to get beer details from my rails api, and I want to show an image from a url that is returned. Example API response description = "Super tasty"; id = 3; "label_url" =…
jacobt
  • 157
  • 3
  • 11
0
votes
4 answers

Pass username and password in URL for authentication

I want ot pass username and password in URL(web service) for user authentication which will return true and false.I'm doing this as following: NSString *userName = [NSString stringWithFormat:@"parameterUser=%@",txtUserName]; NSString *passWord =…
bapi
  • 1,903
  • 10
  • 34
  • 59
0
votes
2 answers

NSUrl adding selection criteria

I have the following code and I cannot work out from the IOS developer documentation how to add some selection criteria (for the PHP) to the url My php works when I add /?category=sports but how to I get this added to my kGETUrl string NSURL *url =…