I believe keys in an NSDictionary/NSMutableDictionary are NSStrings;
they're just descriptive tags you attach (or associate) with an
object (the "value"). What you need is
[sourceButtonMap setObject:[NSString stringWithString:@"no"] forKey:
[unitButton description]];
though you'll have to subclass UIButton and implement a description
method in it for this to do much good.
On May 11, 2010, at 3:36 PM, Alejandro Marcos Aragón wrote:
Hi all,
I'm new to Cocoa, and I couldn't find information about an error
that I'm getting on the web. I'm trying to create an
NSMutableDictionary where the keys are of type UIButton*:
// create button for unit
UIButton* unitButton = [[UIButton alloc] init];
[sourceButtonMap setObject:[NSString stringWithString:@"no"]
forKey:unitButton];
Of course, the sourceButtonMap is defined in the class and
initialized in the init function as sourceButtonMap =
[[NSMutableDictionary alloc] init];
The error I get when I try to add the key-value pair is:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** -[UIButton
copyWithZone:]: unrecognized selector sent to instance 0x3931e90'
Is this happening because I can't store UIButton* as keys?
Can anyone point me why I'm getting this error? Thank you all,
aa_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/wsquires%
40satx.rr.com
This email sent to wsqui...@satx.rr.com
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com