-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtextedit.m
26 lines (19 loc) · 890 Bytes
/
textedit.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Get bridge with: sdef /Applications/iTunes.app | sdp -fh --basename iTunes
// Build with: gcc -ObjC -framework Foundation -framework ScriptingBridge itunes.m
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import <ScriptingBridge/ScriptingBridge.h>
#import "TextEdit.h"
int main()
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
TextEditApplication *textEdit = [SBApplication applicationWithBundleIdentifier:@"com.apple.TextEdit"];
NSLog(@"Documents count = %d", [[textEdit documents] count]);
[textEdit open:[NSURL fileURLWithPath:@"/Users/todd.foster/.profile"]];
NSLog(@"Documents count = %d", [[textEdit documents] count]);
[[[textEdit documents] objectAtIndex:0] saveAs:nil in:[NSURL fileURLWithPath:@"/Users/todd.foster/Desktop/deleteMe.html"]];
[textEdit quitSaving:TextEditSavoNo];
[textEdit release];
textEdit = nil;
[pool release];
}