Re: NSMutableDictionary member access problem
Re: NSMutableDictionary member access problem
- Subject: Re: NSMutableDictionary member access problem
- From: j o a r <email@hidden>
- Date: Fri, 25 Jun 2004 13:31:05 -0700
You have almost certainly created your dictionary using
[NSMutableDictionary dictionaryXXX] which returns an autoreleased
instance, when you wanted an instance with a positive retain count.
Consider using [[NSMutableDictionary alloc] initXXX] to create a
dictionary instance to keep outside of the scope of the current event
loop (ie. the scope of the current autorelease pool) - or
alternatively, send the new instance a retain message.
j o a r
On 2004-06-25, at 13.08, Hisaoki Nishida wrote:
>
I have some code that accesses an object in a NSMutableDictionary.
>
The problem is that I can't see the problem.
>
>
return [db objectForKey: key];
>
>
This is where I get the runtime error saying -[NSCFString
>
objectForKey:]: selector not recognized.
>
>
Whenever I ask an object for key "key" in db, I get this error.
>
And why is it [NSCFString objectForKey:] when it is really
>
[NSMutableDictionary objectForKey:]?
>
>
key is a valid NSString, db is a valid NSMutableDictionary with 200
>
elements in it.
>
I did initialize key using [NSString stringWithFormat: "%d", int]
>
where int is an integer, but there's nothing wrong with it AFAIK.
>
>
>
Thanks for your assitance,
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.