Re: baseURL problem with +fileURLWithPath:
Re: baseURL problem with +fileURLWithPath:
- Subject: Re: baseURL problem with +fileURLWithPath:
- From: Joar Wingfors <email@hidden>
- Date: Tue, 18 May 2010 07:14:08 -0700
On 18 maj 2010, at 04.52, Robert Monaghan wrote:
> This is pretty trivial.. I have a string that is coming from an FCP XML file. The string looks like this:
> file:/localhost/Users/bob/Movies/ARRI/ELAP/shot_1_2/Imagery/Proxies/DMAG001_1_2_TAKE_005_RAWPROXY720P.mov
>
> I then pass the string to an NSURL object using: (Yes, I know I can do a "fileURLWithPath:" -- I am trying to troubleshoot where the problem is.)
> NSURL *url = [[[NSURL alloc] initFileURLWithPath:[[pathurlArray objectAtIndex:0] stringValue]] autorelease];
You're doing it wrong... ;-)
The "-initFileURLWithPath:" and "+fileURLWithPath:" methods takes a string containing a path (would have been "/Users/..." in your example above), not the file-URL representation of that path ("file:/localhost/Users/..." in your example above).
If you already have a string that contains a RFC 2396 compliant representation of a URL, you should be using the "init with string" style initializers to create the URL.
> Then, I try to get an NSString object by doing:
> [url path]
>
> This is where things go wildly wrong.. the NSString value ends up being a path to my binary.
The clue to this behavior can be found in the documentation for CFURL:
"If filePath is not absolute, the resulting URL will be considered relative to the current working directory (evaluated when this function is being invoked)."
Please file a bug report if you think that the documentation should be improved:
<http://developer.apple.com/bugreporter/>
j o a r
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden