Is there any way to use the System icons, located in:/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ without having to add them to the Resource folder of my project in an application with AppleSript?
Asked
Active
Viewed 233 times
1 Answers
0
Yes, just use the POSIX path. If you are using display dialog, AppleScript in Xcode s a bit fussy, so you will need to explicitly coerce it:
display dialog "hello" with icon ("/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericQuestionMarkIcon.icns" as POSIX file)
if you are using NSAlert, the icon property needs to be an image, so you can get one from the path, for example:
set myAlert to current application's NSAlert's alloc's init()
set myAlert's messageText to "hello"
set myAlert's icon to current application's NSImage's alloc's initByReferencingFile:"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericQuestionMarkIcon.icns"
myAlert's runModal()
For other objects that use an NSImage, you can get an image from the path in the same way, and set the object's image by using the relevant property or setter method:
set yourImageView's image to current application's NSImage's alloc's initByReferencingFile:"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/GenericQuestionMarkIcon.icns"

red_menace
- 3,162
- 2
- 10
- 18
-
Thanks for the answer @red_menace, but I did not know how to ask the right question, sorry, I would like to use the icons in an ImageView. – TheOnlyOneHere Jan 11 '19 at 15:08
-
I've updated my answer to include an ImageView - see **NSImage** for other attributes and methods that can be used with the icon (or other) image. – red_menace Jan 11 '19 at 16:02