• 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: stringWithContentsOfURL works when it's a script, not when it's an app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stringWithContentsOfURL works when it's a script, not when it's an app


  • Subject: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • From: Steve Mills <email@hidden>
  • Date: Tue, 04 Oct 2016 22:28:16 -0500

On Oct 4, 2016, at 20:43:25, Shane Stanley <email@hidden> wrote:
>
> It's hard to know — do you mean Apple's Script menu?

Yes.

> I saved this as an app:
>
> use AppleScript version "2.4" -- Yosemite (10.10) or later
> use framework "Foundation"
> use scripting additions
>
> set mainUrl to current application's |NSURL|'s URLWithString:"http://apple.com";
> set {s, err} to current application's NSString's stringWithContentsOfURL:mainUrl encoding:(current application's NSUTF8StringEncoding) |error|:(reference)
> display dialog (s as text)

"http://www.apple.com"; works for me as well, as does any url I've tried that doesn't end in a file. But urls I've tried that do end in a file will not work when the script is an app. Try this one:

http://www.armpitstudios.com/sites/as/Apps.html

Works if I run the .scpt from Script Debugger or from the system Script menu, also works if I run the .app from Script Debugger, but does not work if I run the .app from the system Script menu or by launching it in Finder.

--
Steve Mills
Drummer, Mac geek


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: stringWithContentsOfURL works when it's a script, not when it's an app
      • From: Shane Stanley <email@hidden>
References: 
 >stringWithContentsOfURL works when it's a script, not when it's an app (From: Steve Mills <email@hidden>)
 >Re: stringWithContentsOfURL works when it's a script, not when it's an app (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Is there a way to speed this up?
  • Next by Date: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Previous by thread: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Next by thread: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Index(es):
    • Date
    • Thread