On Sat, 5 Mar 2005 03:01:38 +0900, Tetsuro KURITA <email@hidden> wrote:
> I'm trying using "NSMutableDictionary" as follows. I want to add a new
> entry into an instance of NSMutableDictionary.
>
> set theDict to call method "dictionaryWithCapacity:" of class
> "NSMutableDictionary" with parameter 10
> call method "setValue:aKey:" of theDict with parameters {"hello", "hey"}
> set theDescription to call method "description" of theDict
> log theDescription -- the result of this log statement is "()"
>
> Above code does not works. call method "setValue:aKey:" statement does
> not give any effects. What is wrong ?.
It may be that theDict is getting auto-released, since
dictionaryWithCapacity, and other initializers like it, return an
auto-released object. This is more fully covered in Apple's Cocoa
documentation, but the general gist is that unless you call alloc on
the class, then use an object method to initialize it, the return
value will be auto-released.
The other side of this is that if you do retain theDict, either
through alloc or by calling retain, you need to either call release or
autorelease on it.
If you're working a lot with Cocoa, you should join the cocoa-dev
list. Also read the document on Cocoa memory management, it'll be very
helpful.
James
_______________________________________________
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