• 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
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]

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


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

I have a script I've been using for a while to parse stuff out of web pages. One of the first things it does is to load the page into an NSString (ap is current application):

	set {s, err} to ap's NSString's stringWithContentsOfURL:mainUrl encoding:(ap's NSUTF8StringEncoding) |error|:(reference)

Tonight I thought I'd convert the "display notification" it sends when done into an NSUserNotification so I can accept the click on the notification and do some action. I set "me" as the NSUserNotificationCenter's delegate so I can catch its delegate methods. Since the NSUserNotificationCenter doesn't belong to "me" when it's run as a script from the script menu, I changed it to a script app (at least that's what I assume, as my delegate methods didn't get called). Now stringWithContentsOfURL no longer works. It returns error:

The file “blah.html” couldn’t be opened.

Any ideas why this is failing? Am I going to have to make this more complicated and spawn an NSTask to download it via curl or something?

--
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>
  • Prev by Date: Re: Placing a new Unix command inside me
  • Next by Date: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Previous by thread: Re: Is there a way to speed this up?
  • Next by thread: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Index(es):
    • Date
    • Thread