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 pass * () $ etc in NSUrl?

I tried to pass these characters to server, for example *()$ I have coded the NSUrl this way: NSString *partialURL = [NSString stringWithFormat:@"/%@", commentBody]; NSString *fullURL = [NSString stringWithFormat:@"%@%@", CONST_URL,…
Rendy
  • 5,572
  • 15
  • 52
  • 95
0
votes
2 answers

Append String with NSURL

I have following string , which i want to append with NSURL and after appending i want the result in NSURL { "deviceid":"3c27c99ac4b159aca81de8f5d266478f00000000…
Viru1987
  • 13
  • 4
0
votes
2 answers

NSURL - Set modify path

I need to use a NSURL object to reach different ressources on the same host. Here is what I do: #define MY_HOST @"my.server.eu" NSURL *url = [[NSURL alloc] initWithScheme:@"http" host:MY_HOST path:@"/"]; Now I need to deal…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
0
votes
2 answers

Error with stringWithContentsOfURL encoding with à è ò ù character

I have a problem with this implementation: NSString *s = [NSString stringWithContentsOfURL:[NSURL URLWithString:site] encoding:NSUTF8StringEncoding error:&er]; the string site contains this character with the accent, for example : à è ò ù and every…
Piero
  • 9,173
  • 18
  • 90
  • 160
0
votes
1 answer

Image at URL failing to populate NSData

I have an image at a URL which is failing to load into an NSData. When I paste the image URL into a Chrome incognito window, it displays successfully. However, the following fails: photoData = [[NSData alloc] initWithContentsOfURL:[NSURL…
Steven
  • 1,049
  • 2
  • 14
  • 32
0
votes
2 answers

Pure C++ equivalent for NSURLConnection and NSURLRequest

I am porting a game using native C++ for Android. I need to know which method I should use to achieve the same functionality as NSURLConnection and NSURLRequest in only C++. Also how to get all the following delegate functions implemented for…
user1908860
  • 509
  • 1
  • 9
  • 19
0
votes
5 answers

iOS NSURL to NSString

I am trying to read the text from this file and display it in a label on my app. I am getting an error message with this piece of code. NSURL *url = [NSURL URLWithString:@"http://www.funnynewsletter.tk/files/file.txt"]; NSString *content = [NSString…
user1529476
0
votes
1 answer

NSBundle File References Lost After App Reinstalled

I save a user preference for an audio file in NSUserDefaults with a URL built like this: soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audioFile1.m4r", [[NSBundle mainBundle] resourcePath]]]; That preference is subsequently…
Michael Mangold
  • 1,741
  • 3
  • 18
  • 32
0
votes
4 answers

ios - NSString losing content when used in NSUrl

I have the following code - note it has to objects with temp, but I will explain. NSString *temp = _passedOnURL; NSString *temp = @"http://google.com"; //I comment the one out that I do not use. NSLog(@"TEMP - %@", temp); NSURL *feedURL = [NSURL…
jwknz
  • 6,598
  • 16
  • 72
  • 115
0
votes
2 answers

Tableview Images Loading Slowly

I am trying to load image from a JSON feed into a tableview. The code below returns the images but it is making the app very very slow and "sticky". Any ideas on how to make it faster? This is being called for each cell in the tableview. NSURL…
Brandon
  • 2,163
  • 6
  • 40
  • 64
0
votes
2 answers

Can't POST a request to service

For some reason I always get Endpoint not found., but when I put it in the browser it works perfectly. I'm sure doing something wrong.. - (void)requestLoad:(NSString *)req_udid Age:(NSString *)req_age Gender:(NSString *)req_gender…
ytpm
  • 4,962
  • 6
  • 56
  • 113
0
votes
1 answer

Detect if NSURL is a URL to a file format supported by the UIImage class

I'm looking for a way to detect a if an NSURL is a URL to a file format supported by the UIImage class, and if yes, open it in something like MWPhotoBrowser (https://github.com/mwaterfall/MWPhotoBrowser) instead of a UIWebView. My first thought is…
Sam J.
  • 685
  • 1
  • 8
  • 22
0
votes
1 answer

ios - making a remote call works on emulator but can not get it to work from live devices

I have a bit of a confusing situation. I have a form after which I create a url and make an asynchronous server call. That data does not need to be secure. Here is what I have: NSString *urlString =…
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
0
votes
1 answer

NSURLDownload downloadDidFinish: called too early

One of the main components of the the OS X application I work on is a downloading system, which is built around NSURLDownload. The vast majority of our users (as well as our internal dev team) don't have any issues with downloading files. However we…
philbert1
  • 143
  • 6
0
votes
0 answers

preload NSURL via didFinishLaunchingWithOptions and call in ViewController-webview

I want to preload an URL via " didFinishLaunchingWithOptions" if my app starts. At this time I call the URL in the ViewController directly, but it takes too long to the the content, so I want to see the content from the URL directly. At this time…
webschnecke
  • 919
  • 1
  • 8
  • 21
1 2 3
99
100