AppleScript名:指定クラスがどのFrameworkに所属しているか検索 v3 |
— Created 2017-10-14 by Shane Stanley — Modified 2017-10-14 by Takaaki Naganoya use AppleScript version "2.4" use scripting additions use framework "Foundation" set fRes1 to searchClassInFrameworks("JSContext") of me –> "JavaScriptCore.framework" set fRes2 to searchClassInFrameworks("NSApplication") of me –> "AppKit.framework" set fRes3 to searchClassInFrameworks("NSRect") of me –> false set fRes4 to searchClassInFrameworks("PDFPage") of me –> "Quartz.framework" set fRes5 to searchClassInFrameworks("NSUTF8StringEncoding") of me –> false set fRes6 to searchClassInFrameworks("CIColor") of me –> "CoreImage.framework" on searchClassInFrameworks(aTarget) set aClass to current application’s NSClassFromString(aTarget) if aClass = missing value then return false set theComponenents to (current application’s NSBundle’s bundleForClass:aClass)’s bundleURL’s pathComponents() set thePred to current application’s NSPredicate’s predicateWithFormat:"pathExtension == ’framework’" set aRes to (theComponenents’s filteredArrayUsingPredicate:thePred)’s firstObject() as text return aRes end searchClassInFrameworks |
(Visited 28 times, 1 visits today)
現在実行中のアプリケーションがloadしているFramework名を取得 – AppleScriptの穴 says:
[…] それとも、アホなScripterがuse framework宣言を行わずにScriptを書いてしまう(チェックプログラムを書くまでよくやっていた)ことを防ぐために多めにFrameworkを呼び出しているものでしょう […]