• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: new to cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new to cocoa


  • Subject: Re: new to cocoa
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 14 May 2010 09:38:40 -0700


On May 11, 2010, at 1:36 PM, Alejandro Marcos Aragón wrote:

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*:

Sounds like you're trying to associate data values with buttons. The easiest way to do this is to use the control's existing 'tag' property, which lets you store an arbitrary integer value. [Actually I'm not certain that UIKit controls have tags; their corresponding AppKit classes in Mac OS do.]


If you need to store a non-integer value, or have to use a dictionary for some other reason, you can use [NSValue valueWithPointer: button] to create a value object wrapping a pointer to your button. Those values can be used as dictionary keys. To unwrap one, use (UIButton*) [value pointerValue]. Just make sure to remove the associated key object when a button is deleted, otherwise it's a dangling pointer to a deleted object and will cause a crash if you try to use that button pointer again.

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >new to cocoa (From: Alejandro Marcos Aragón <email@hidden>)

  • Prev by Date: Re: NSArrayController Undo
  • Next by Date: Re: AsyncUdpSocket: Receiving duplicate UDP Packet
  • Previous by thread: Re: new to cocoa
  • Next by thread: Re: new to cocoa
  • Index(es):
    • Date
    • Thread