• 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
Calling AppleScript from delegate methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling AppleScript from delegate methods


  • Subject: Calling AppleScript from delegate methods
  • From: Steve Mills <email@hidden>
  • Date: Wed, 05 Oct 2016 23:08:05 -0500

Are there limitations to calling stuff from a delegate method? The userNotificationCenter:didActivateNotification: handler below is being called, but the line "set f to folder pf" errors with:

2016/10/05 23:00:30.467 applet[4468]: *** -[BAGenericObjectNoDeleteOSAID userNotificationCenter:didActivateNotification:]: Finder got an error: Can’t make «class ocid» id «data optr0000000050E2D454817F0000» into type integer. (error -1700)

The script is saved as an app with Stay Open turned on. This happens when I run the script from Script Debugger or from the system script menu. And I've set the bundle ID to com.apple.wtf.


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"

property ap : a reference to current application

global destFold

on run
	set destFold to "~/Users/tut/Pictures/"
	set noti to ap's NSUserNotification's alloc's init
	set noti's title to "Done"
	set noti's informativeText to "Stuff!"
	set noti's hasActionButton to true

	set notiCenter to ap's NSUserNotificationCenter's defaultUserNotificationCenter
	set notiCenter's delegate to me
	notiCenter's deliverNotification:noti
end run

on userNotificationCenter:center didActivateNotification:notification
	set pf to POSIX file destFold

	tell application "Finder"
		activate
		set f to folder pf
		open f
	end tell

	quit
end userNotificationCenter:didActivateNotification:

on userNotificationCenter:center shouldPresentNotification:notification
	return true
end userNotificationCenter:shouldPresentNotification:

--
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: Calling AppleScript from delegate methods
      • From: Shane Stanley <email@hidden>
    • Re: Calling AppleScript from delegate methods
      • From: Steve Mills <email@hidden>
  • Prev by Date: Re: stringWithContentsOfURL works when it's a script, not when it's an app
  • Next by Date: Re: Calling AppleScript from delegate methods
  • Previous by thread: Re: Accessibility
  • Next by thread: Re: Calling AppleScript from delegate methods
  • Index(es):
    • Date
    • Thread