• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSAppleScript - what is going on here?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAppleScript - what is going on here?


  • Subject: NSAppleScript - what is going on here?
  • From: Steve Cronin <email@hidden>
  • Date: Sat, 21 Mar 2009 12:38:11 -0500

Folks;

I'm trying to get a string value back from a simple AppleScript in Cocoa:

NSDictionary *errorDict= nil;
NSAppleScript *appleScriptObject = [[NSAppleScript alloc] initWithSource:theScript];
NSAppleEventDescriptor *eventDescriptor = [appleScriptObject executeAndReturnError: &errorDict];
[appleScriptObject release];
if (([eventDescriptor descriptorType]) && (errorDict==nil)) {
return [self stringFromAppleEventDescriptor:eventDescriptor]; //my own method that checks descriptorType and returns stringValue
} else {
NSLog(@"%@",[errorDict objectForKey:@"NSAppleScriptErrorMessage"]);
return nil;
}


The 'theScript' is a valid script that executes flawlessly in 'Script Editor':
tell application "Finder"
try
comment of file ("/Users/steve/...." as POSIX file)
on error
return "Error"
end try
end tell


The problem is that the above errors out @ [appleScriptObject executeAndReturnError: &errorDict];
The stack is shown below.


What am I overlooking here?
Steve
____________________________
#0 0x9543c1ab in CFDataGetBytePtr
#1 0x90462218 in XMLDataResolvingXIncludes
#2 0x90464fa8 in OSACopyScriptingDefinition
#3 0x90861531 in -[NSScriptSuiteRegistry loadSuitesFromBundle:]
#4 0x90860ede in -[NSScriptSuiteRegistry _loadSuitesForAlreadyLoadedBundles]
#5 0x90860bd4 in -[NSScriptSuiteRegistry init]
#6 0x90860b44 in +[NSScriptSuiteRegistry sharedScriptSuiteRegistry]
#7 0x908608d9 in +[NSScriptSuiteRegistry _loadScriptSuites]
#8 0x907b7f1c in _nsnote_callback
#9 0x954568da in __CFXNotificationPost
#10 0x95456bb3 in _CFXNotificationPostNotification
#11 0x907b5080 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#12 0x907be8c8 in -[NSNotificationCenter postNotificationName:object:]
#13 0x90873650 in -[NSAppleEventManager(NSInternal) _sendDidFailToDispatchNotification]
#14 0x90873574 in _NSAppleEventManagerPreDispatchHandler
#15 0x952e9648 in aeDispatchAppleEvent
#16 0x952f27be in AESendMessage
#17 0x952f55ab in aeSend
#18 0x957985af in AESend
#19 0x01be917a in AEDefaultSendProc
#20 0x01becdfd in ComponentSend
#21 0x01becfc0 in SendSimpleEventWithReply
#22 0x01bd4c3d in ScanForScriptingAdditions
#23 0x01bd4f07 in ASInitLocal
#24 0x01bd4fa5 in ASDefaultInit
#25 0x01bcca2d in AppleScriptComponent
#26 0x93fdda05 in CallComponentDispatch
#27 0x90456af8 in OSASetActiveProc
#28 0x01be86c4 in AGenericManager::UpdateInstanceProcs
#29 0x01be87e2 in AGenericManager::ComponentFromSubtype
#30 0x01be8915 in AGenericManager::DefaultComponentInstance
#31 0x01be811c in AGenericCall::PreDelegate
#32 0x01be88c9 in AGenericManager::HandleOSACall
#33 0x93fdda05 in CallComponentDispatch
#34 0x904681c3 in OSACompile
#35 0x908a13b8 in -[NSAppleScript compileAndReturnError:]
#36 0x908a16a6 in -[NSAppleScript(NSPrivate) _executeWithMode:andReturnError:]
#37 0x908a1461 in -[NSAppleScript executeAndReturnError:]



_______________________________________________

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


  • Follow-Ups:
    • Re: NSAppleScript - what is going on here?
      • From: "Adam R. Maxwell" <email@hidden>
    • Re: NSAppleScript - what is going on here?
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: Send events to AppleScript
  • Next by Date: Re: Threaded Server using Distributed Objects
  • Previous by thread: Parameters Bindings
  • Next by thread: Re: NSAppleScript - what is going on here?
  • Index(es):
    • Date
    • Thread