Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing AppleScript Records with Variable Identifiers



On 7/4/05 2:30 PM, "Matt Neuburg" <email@hidden> wrote:

>> Date: Sat, 02 Jul 2005 14:38:40 -0700
>> From: Paul Berkowitz <email@hidden>
>> Subject: Re: Changing AppleScript Records with Variable Identifiers
> 
>> NSDictionary
>> is precisely a "rigid" immutable data structure: it's much more rigid than
>> an AS record in that you can't change the value of keys.
> 
> Ouch. There goes my bullshit meter, redlining again.
> 
>     NSMutableString* s =
>         [NSMutableString stringWithString:@"howdy"];
>     NSDictionary* d =
>         [NSDictionary dictionaryWithObject:s forKey:@"greeting"];
>     NSLog(@"%@",d); // {greeting = howdy; }
>     [s setString: @"hello"];
>     NSLog(@"%@",d); // {greeting = hello; }
> 
> No "more rigid" than an AS record. m.

Sure it is. That's a trick answer that you've set up to get around the
limitations. If a dictionary's objects have all been defined to be mutable
in the first place and you change the value of an object to another value of
the same type without replacing the object, sure, OK. Not all types of
objects can be defined as mutable, however.  Want to try changing an
NSNumber to another number? (Or to a string? Or to an application object?)
The equivalent of changing the value of a property in an AppleScript record
is setValue:forKey: in an NSMutableDictionary, which you cannot do in an
NSDictionary. That's what NSMutableDictionary is for. An AppleScript record
is somewhere between the two types (no equivalent of removeObjectForKey: or
setObject:forKey: although there are easy ways to redefine a record to do
those).

-- 
Paul Berkowitz

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: Changing AppleScript Records with Variable Identifiers (From: Matt Neuburg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.