stringWithContentsOfURL works when it's a script, not when it's an app
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