पर प्रतिक्रिया दें, मैं कोको एप्लिकेशन में एक छोटा ऐप्पलस्क्रिप्ट समर्थन जोड़ने की कोशिश कर रहा हूं। आवेदन समय-समय पर चेक करता है और मैं इसे मांग पर प्रदर्शन करने के लिए कहने में सक्षम होना चाहता हूं।कोको एप्लिकेशन को सरल ऐप्पलस्क्रिप्ट कमांड
मैं SimpleScriptingVerbs ऐप्पल उदाहरण का पालन करने की कोशिश कर रहा हूं।
मैं NSScriptCommand
subclassed है इस प्रकार है:
हैडर:
#import <Cocoa/Cocoa.h>
@interface rdrNotifierUpdateCommand : NSScriptCommand {
}
-(id)performDefaultImplementation;
@end
कार्यान्वयन:
#import "rdrNotifierUpdateCommand.h"
#import "rdrNotifierAppDelegate.h"
@implementation rdrNotifierUpdateCommand
-(id)performDefaultImplementation {
NSLog(@"Works at last");
[((rdrNotifierAppDelegate *)[[NSApplication sharedApplication] delegate])
checkForNewItems]; // This just fires the timer
return nil;
}
@end
मेरे .sdef
फ़ाइल इस प्रकार है (और समस्या हो रहा है, लेकिन मैं इसे नहीं मिला):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="Dictionary" xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>
<suite name="rdrNotifier Suite" code="rdrN" description="rdrNotifier application specific scripting facilities.">
<command name="do update" code="rdrNUpdt" description="Check for new items">
<cocoa class="rdrNotifierUpdateCommand"/>
</command>
</suite>
</dictionary>
Info.plist
उचित रूप से स्थापित किया गया है।
लेकिन, जब मैं AppleScript संपादक में निम्न स्क्रिप्ट चलाने का प्रयास:
tell application "rdrNotifier"
do update
end tell
मैं चर "अद्यतन" के बारे में कोई त्रुटि प्राप्त परिभाषित नहीं किया जा रहा।
मैं ऐप्पलस्क्रिप्ट संपादक से अपने आवेदन के लिए शब्दकोश खोल सकता हूं (यानी यह सफलतापूर्वक पंजीकृत है)।
संपादित करें: मिला एक समाधान
समस्या sdef
फ़ाइल में वास्तव में था: मैं निर्दिष्ट नहीं किया गया था कि आवेदन आदेश का जवाब दे सकते।
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
<dictionary title="Dictionary" xmlns:xi="http://www.w3.org/2003/XInclude">
<!-- I have removed the standard suite as the application does not open, print... -->
<suite name="rdrNotifier Suite" code="rdrN" description="rdrNotifier application specific scripting facilities.">
<command name="do update" code="rdrNUpdt" description="Check for new items">
<cocoa class="rdrNotifierUpdateCommand"/>
</command>
<class name="application" code="Capp">
<cocoa class="NSApplication"/>
<responds-to name="do update">
<!-- Note you need to specify a method here,
although it is blank -->
<cocoa method=""/>
</responds-to>
</class>
</suite>
</dictionary>
किसी भी सुधार/सुझावों/आलोचनाओं अभी भी स्वागत कर रहे हैं: मेरा अंतिम परिभाषा के रूप में (Obj सी कोड में कोई बदलाव नहीं) इस प्रकार चला जाता है।
मुझे तकनीकी को इंगित करने के लिए बहुत बहुत धन्यवाद।हां, "अद्यतन करें" मूर्खतापूर्ण लगता है; "करना" डालना (मेरा मतलब था "प्रदर्शन", लेकिन इसका उपयोग करने से बहुत अधिक मदद नहीं होगी) कोई समझ नहीं आता है। मैंने कोड को एक क्रिया में बदल दिया है और, वास्तव में, "अपडेट" भी फेंक दिया और "रीफ्रेश" के साथ समाप्त हो गया। –
ताज़ा लगता है महान! :) बहुत ताज़ा – brennanyoung
मैं यह देखने में असफल रहा कि यह दूरस्थ रूप से एक उत्तर कैसे है। – Volomike