首先,我是Obj-C的新手,请放轻松对待我:D
我正在构建一个应用程序,它基本上与AppleScript编辑器的功能相同。
我使用过OSAScriptView,我想要做的是将此OSAScriptView的内容保存为预定义文件夹中的.scpt文件。 (如/documents/myscripts/newscript.scpt)
提前致谢!
答案 0 :(得分:2)
班级OSAScript
包含您要查找的方法。
@interface OSAScript : NSObject
// Instance Members
- (BOOL)compileAndReturnError:(NSDictionary**)errorInfo;
- (BOOL)isCompiled;
- (BOOL)writeToURL:(NSURL*)url ofType:(NSString*)type error:(NSDictionary**)errorInfo;
- (BOOL)writeToURL:(NSURL*)url ofType:(NSString*)type usingStorageOptions:(OSAStorageOptions)storageOptions error:(NSDictionary**)errorInfo;
- (NSAppleEventDescriptor*)executeAndReturnDisplayValue:(NSAttributedString**)displayValue error:(NSDictionary**)errorInfo;
- (NSAppleEventDescriptor*)executeAndReturnError:(NSDictionary**)errorInfo;
- (NSAppleEventDescriptor*)executeAppleEvent:(NSAppleEventDescriptor*)event error:(NSDictionary**)errorInfo;
- (NSAppleEventDescriptor*)executeHandlerWithName:(NSString*)name arguments:(NSArray*)arguments error:(NSDictionary**)errorInfo;
- (NSAttributedString*)richTextFromDescriptor:(NSAppleEventDescriptor*)descriptor;
- (NSAttributedString*)richTextSource;
- (NSData*)compiledDataForType:(NSString*)type usingStorageOptions:(OSAStorageOptions)storageOptions error:(NSDictionary**)errorInfo;
- (NSString*)source;
- (NSURL*)url;
- (OSALanguage*)language;
- (id)initWithCompiledData:(NSData*)data error:(NSDictionary**)errorInfo;
- (id)initWithContentsOfURL:(NSURL*)url error:(NSDictionary**)errorInfo;
- (id)initWithContentsOfURL:(NSURL*)url language:(OSALanguage*)language error:(NSDictionary**)errorInfo;
- (id)initWithSource:(NSString*)source language:(OSALanguage*)language;
- (id)initWithSource:(NSString*)source;
- (void)setLanguage:(OSALanguage*)language;
您可以自己创建,或使用类OSAScriptController
,它将自动创建一个。