是否可以在OSX 10.7中從AppleScript調用Objective-c類?在OSX 10.7中調用AppleScript中的Objective-c類10.7
我看到了一些關於Snow Leopard或更早版本的建議,但似乎沒有任何效果。 AppleScript-Obj-C似乎是構建使用AppleScript的GUI的一種方式,但我想調用我從腳本中寫入的類。
以下(不工作)是我希望做什麼: -
on getJpegComment(photoFile)
set aJpeg to call method "initWithPath" of class "JpegCom" with parameter photoFile (does not work)
return call method "comment" of aJpeg
end getJpegComment
tell application "iPhoto"
tell album "Sale"
set thePhotos to get every photo
end tell
repeat with aPhoto in thePhotos
tell application "iPhoto"
set aPhotoFile to image path of aPhoto
set aComment to my getJpegComment(aPhotoFile)
set comment of aPhoto to aComment
end tell
end repeat
end tell
我開始沿着這條道路,因爲這似乎表明這是可能的鏈接。
我可以編寫一個名爲AppleScript的Objective-c程序,但這看起來似乎過於簡單。
PS我有成千上萬的照片,我輸入了Windows的JPEG視頻,不幸的是iPhoto不理解這些。
那麼你使用的是applescript-objc嗎? – TheAmateurProgrammer 2012-03-26 01:24:40
「call method」來自AppleScript Studio,它在Snow Leopard中已棄用。 AppleScriptObjC可以調用Objective-C類,反之亦然,除了能夠直接調用Cocoa類方法 - 什麼是類「JpegCom」? – 2012-03-26 01:35:51
感謝所有評論。 我開始懷疑你不能從AppleScript調用Objective-C。 我曾嘗試使用Xcode創建AppleScriptObjC應用程序,但我不想要GUI - 只是一個簡單的腳本。我能找到的所有例子都是GUI(並且製作Objective-C應用程序要容易得多)。如果我可以使用我的主腳本,並且在AppleScriptObjC中提供了一個處理程序,這將是理想的。 – Milliways 2012-03-27 00:42:07