• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating an NSURL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating an NSURL


  • Subject: Re: Creating an NSURL
  • From: Darrin Cardani <email@hidden>
  • Date: Fri, 14 Nov 2003 09:59:43 -0600

At 6:27 PM -0800 11/13/03, Darrin Cardani <email@hidden> wrote:
I have an NSMovieView, and I want to save the reference to the movie
file it contains. I get the movie's URL by doing this:

NSMovie* theMovie = [ movieView movie ];
NSURL* movieURL = [ theMovie URL ];
NSString* movieStr = [ movieURL absoluteString];

This gives me a string containing URL of this type:

file://localhost/path/to/movie.mov

I save that in an XML file. I can open the XML file in a text editor
and look at it, and it is correctly saved.

However, when I attempt to read it back in, I have the string above
in an NSString, and I do the following:

NSString* moviePath = the string from the XML file
NSURL* movieURL = [ NSURL URLWithString:moviePath ];

That returns nil for movieURL, which would lead me to believe that
moviePath isn't well-formed according to RFC 2396, since that's the
one case the docs for [ NSURL URLWithString ] mention as returning
nil.

I figured it out. It turns out that the URL had a couple of carriage returns and tabs in front of it from the way I read it out of the XML file. It didn't occur to me when I saw it printed to the console that the extra whitespace around it was actually in the string, and not NSLog being helpful.

Thanks,
Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Xcode - Other Linker
  • Next by Date: Re: fileSystemAttributesAtPath on Panther
  • Previous by thread: Creating an NSURL
  • Next by thread: Two dimensional array
  • Index(es):
    • Date
    • Thread