Topher
-----Original Message-----
From: Tim Bumgarner [mailto:email@hidden]
Sent: Friday, July 01, 2005 11:32 AM
To: Christopher Hickman
Cc: 'AppleScriptStudio MailingList'
Subject: Re: Result of Obj-C Code Differs from call method to Same
Methods
Cocoa scripting does the work of translating AppleScript objects to
Cocoa objects, like a record to a NSDictionary. The problem is that
it always uses the immutable variant of said objects:
list <--> NSArray
record <--> NSDictionary
not:
list <--> NSMutableArray
record <--> NSMutableDictionary
This is primarily for performance reasons. There currently isn't an
easy solution that will work around this problem. Doing the mutable
work inside the Objective-C code is the only viable alternative.
Tim Bumgarner
Apple Computer
On Jul 1, 2005, at 11:25 AM, Christopher Hickman wrote:
Oh, incidentally, does someone with intimate knowledge of the inner
workings
of AppleScript (*cough* Chris Nebel *cough*) know why this
Objective-C code
works, but the equivalent call method calls from AppleScript
*don't* work?
- (NSDictionary *)setRecord:(NSDictionary *)theRecord label:
(NSString *)
theLabel toValue:(id *) theValue;
{
NSMutableDictionary mutableRecord = [NSMutableDictionary
dictionaryFromDictionary:theRecord];
[mutableRecord setObject:theValue forKey:theKey];
return [autorelease mutableRecord];
}
Using call method to call this method works:
(given myRecord, myLabel, myValue)
set myRecord to (call method "setRecord:label:toValue" of
myClassWithMethod
with parameters {myRecord,myLabel,myValue})
--result: entry in myRecord with label myLabel is now equal to
myValue
But using call method to duplicate the logic within the method
doesn't work:
(again, given myRecord, myLabel, myValue)
set mutableRecord to (call method "dictionaryFromDictionary:" of
class
"NSMutableDictionary" with parameter myRecord
call method "setObject:forKey:" of mutableRecord with parameters
{myValue,myLabel}
set myRecord to mutableRecord
--result: myRecord is unchanged
Anybody know what gives?
Topher
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/tbumgarner
%40apple.com
This email sent to email@hidden