Need to convert string to URL, please help...

Help my friends,

I need to convert a string to an URL like this:


this is not working:

set theXmlFile to "file://localhost/Users/bernardo/Documents/Electronic%20Invoices/XML/000001-Eduardo%20Renam%20G.%20Polinati%20Com.%20ME.xml"

set theXmlFile to theXMLFile's |URL|()

I get:

unrecognized function URL. (error -10000)

Thank you for your kind reply.



There is no URL() method in class NSString. You have to create an NSURL object

 set URLString to "file://localhost/Users/bernardo/Documents/Electronic%20Invoices/XML/000001-Eduardo%20Renam%20G.%20Polinati%20Com.%20ME.xml"
  set theXmlFile to current application's class "NSURL"'s URLWithString_(URLString)

If you create an NSURL object and set it to be the NSURL class then you can use it’s init methods to define an NSURL.

It should look like so:

property NSURL:class “NSURL”

set MyURL to NSURL’s fileURLWithPath_(file_path)

Thanks Stefan and Julio.

It works!