Saving Contents of OSAScriptView as a ".scpt" file into a predefined folder
First, I'm开发者_如何学编程 totally new to Obj-C please go easy on me :D
I'm building an application, which basically does the same thing that AppleScript Editor does.
I have used an OSAScriptView, and what I would like to do is to save the contents of this OSAScriptView as a .scpt file in a predefined folder. (like /documents/myscripts/newscript.scpt)
Thanks in advance!
The class OSAScript
contains the method you are looking for.
@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;
You can create it yourself, or use the class OSAScriptController
, which will create one automatically.
精彩评论