Wait for applescript to complete
Wait for applescript to complete
- Subject: Wait for applescript to complete
- From: Andrew James <email@hidden>
- Date: Wed, 11 Jul 2007 18:24:08 +0930
I have this problem with my code, i use a apple script to communicate
with iSync however i need the script to finish before i run
BTFinishSession() which resets their bluetooth to its original state,
so the question is how do i make it wait for the AS to finish?
BTRequestSession();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *source = @"tell application \"System Events\" \nset
iSync_Running to (exists process \"iSync\")\nend tell\ntell
application \"iSync\"\nlaunch\nif not syncing then\nsynchronize\nend
if\nif not iSync_Running then\nrepeat while syncing\ndelay 1\nend
repeat\nquit\nend if\nend tell";
NSAppleScript *as = [[NSAppleScript alloc] initWithSource:source];
[as executeAndReturnError:nil];
BTFinishSession();
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc]
initWithDateFormat:@"%X" allowNaturalLanguage:NO] autorelease];
NSDate *date = [NSDate date];
NSString *formattedDateString = [dateFormatter stringFromDate:date];
[lastSyncedItem setTitle:[NSString stringWithFormat:@"Last
synchronized : %@", formattedDateString]];
[[NSUserDefaults standardUserDefaults] setObject:formattedDateString
forKey:@"lastSync"];
[[NSUserDefaults standardUserDefaults] synchronize];
[as release];
[pool release];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden