• 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: dictionary as contextInfo in alert sheet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dictionary as contextInfo in alert sheet


  • Subject: Re: dictionary as contextInfo in alert sheet
  • From: Ron Fleckner <email@hidden>
  • Date: Wed, 2 May 2007 18:23:43 +1000


On 02/05/2007, at 5:56 PM, j o a r wrote:


On 2 maj 2007, at 09.37, Ron Fleckner wrote:

I want to pass a dictionary as the context info in an alert sheet. I'm using NSBeginAlertSheet(). If I add a button to the sheet and pass that button as the contextInfo, I can access the button's (switch button) value OK in the sheet's didEnd method. But for some reason that I don't know, passing a dictionary doesn't work. My goal is to pass the button as well as an int (wrapped as an NSNumber of course).


You probably have a memory management error with passing the dictionary.

Try to retain the dictionary before passing it as the context, and then release it when you get it back and and are done with it.

I'll leave it as an exercise for the reader to figure out why you might need to do this, and why you wouldn't need to do it for the button!


Passing the button with the context dictionary should in the general case not be necessary, as if you have a reference to the button before opening the sheet, you typically also have a reference to it in the callback method after the sheet is closed. Obviously, you might have a design where this is not the case.



j o a r



Well, of course that worked. Thanks very much. I can usually recognise a memory error, but was distracted by the button working. Now I'll have to do the 'exercise for the reader'. The button isn't an IBOutlet. It's made in code. I've no idea why the button doesn't need to be retained and the dictionary does. But, there's always the docs. I'll have a look see if I can work it out.


Thanks again,

Ron
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: dictionary as contextInfo in alert sheet
      • From: "Shawn Erickson" <email@hidden>
References: 
 >dictionary as contextInfo in alert sheet (From: Ron Fleckner <email@hidden>)
 >Re: dictionary as contextInfo in alert sheet (From: j o a r <email@hidden>)

  • Prev by Date: Re: dictionary as contextInfo in alert sheet
  • Next by Date: NSRulerView background color
  • Previous by thread: Re: dictionary as contextInfo in alert sheet
  • Next by thread: Re: dictionary as contextInfo in alert sheet
  • Index(es):
    • Date
    • Thread