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
3 answers

How to refresh a browser url from OS x app

I am opening a url from my OS x app. I am doing it as below [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]]; I am doing it on a button action. But whenever I press the button a new tab is opened for me. Can I prevent it in…
Advaith
  • 1,087
  • 3
  • 12
  • 31
0
votes
2 answers

How to check if NSData has a multimedia content?

I have a NSData object, obtained from a URL request.Now I don't know how to read it. However in my application I don't know if the data contains a video or not, so I would know: How to know if NSData has some video inside it? How to interpret the…
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
0
votes
1 answer

Need proper way to add variable to URLWithString

I have a variable called "sellPhone". I want to add it into the URLWithString. What is proper code to do so? - (IBAction)buttonCall:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *sellPhone = [defaults…
mreynol
  • 309
  • 3
  • 17
0
votes
2 answers

Press a Button and open a URL in another ViewController

I am trying to learn Xcode by making a simple app. But I been looking on the net for hours (days) and I cant figure it out how I make a button that open a UIWebView in another ViewController :S first let me show you some code that I have ready: I…
D79
  • 11
  • 5
0
votes
4 answers

How to send NSArray to web service

I have no success to send NSArray to web service. Service method is not called. But other service methods call works. Web service method is: [WebMethod] public int Method(IList items){... My array is full of objects Items: @interface Item :…
1110
  • 7,829
  • 55
  • 176
  • 334
0
votes
1 answer

iOS: How can I add credentials to my code for my NSURL?

I'm trying to access a page that has xml I'm trying to parse. I'm using the following code which works as long as I do not need credentials. How can I add credentials to this code? NSURL *url = [[NSURL alloc] initWithString:URLPath]; NSXMLParser…
daveomcd
  • 6,367
  • 14
  • 83
  • 137
0
votes
1 answer

image retrieved from url does not fit properly into UIImageView

I'm trying to download an image from an url and display into a cell (sample below): NSURL *url = [NSURL URLWithString:@"http://images.google.com/intl/en_ALL/images/logos/images_logo_lg.gif"]; NSData *data = [NSData…
user1372829
  • 1,121
  • 1
  • 11
  • 21
0
votes
1 answer

Trim any illegal characters from NSURL before writing to disk

I would like to write a string to an NSURL which may contain characters such as / or :, which are not supported by the file system. Is there any convenience method to trim these characters? Or maybe a reference containing all illegal characters, so…
fabian789
  • 8,348
  • 4
  • 45
  • 91
0
votes
1 answer

Preserve Folder Hierarchy in IOS for html files

I am trying to include a folder structure into my xcode project that contains html, css, js and images like below: htmlcontent html test.html css test.css js test.js I copied the folder and its subfolder to xcode…
Scoota P
  • 2,622
  • 7
  • 29
  • 45
0
votes
2 answers

NSURL object not an Objective-C object

I am trying to make a URL with a string using the following code NSString *urlStr = [NSString stringWithFormat:@"http://demo.com"]; NSURL *url = [NSURL urlWithString:urlStr]; But the URL is always coming up nil. When I print description of the URL,…
Vishal Singh
  • 4,400
  • 4
  • 27
  • 43
0
votes
2 answers

XCode iOS replace spaces with +

Need help to replace my spaces from the textfield entry for posting to a GET My current code: NSString* urlString = [NSString stringWithFormat:@"http://server.com/ios/add.php?user=iPhone+App&message=%@", messageBox.text]; NSURL *add = [NSURL…
Emil Elkjær
  • 685
  • 1
  • 9
  • 31
0
votes
2 answers

NSURLConnection Unable to http post large file

We are trying to add in functionality into our app to allow it to POST a large file approx 50kb to our web service the file itself is a HTML template, however with the code below what we are finding is that the data seems to get cut off when the web…
MonkeyBlue
  • 2,234
  • 6
  • 31
  • 41
0
votes
2 answers

Need a way to build an NSURL correctly

I am storing website addresses from users in regular NSStrings. Some are given as "www.somewebsite.com" and some as "http://somewebsiteothersite.org". My app should open a UIWebView and open that webpage: NSURLRequest *requestObj =…
Ted
  • 3,805
  • 14
  • 56
  • 98
0
votes
1 answer

NSURL Request not working

I am building an app that would run a website through my app. Basically the webView. I had no problems so far since the last xCode update. It basically runs with no errors but it does not work on iOs 6 simulator or device. .h fle: @interface…
Al K
  • 141
  • 2
  • 11
0
votes
1 answer

Why NSURL query doesn´t work

I hope someone can help me because I'm frustrating. I can´t figure out why if I execute : fileURL = [NSURL URLWithString:@"http://myweb.com/my.pdf"]; then I can display the file correctly in a QLpreviewController but If I execute fileURL = [NSURL…
user1312508
  • 183
  • 2
  • 10
1 2 3
99
100