• 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: File choose context info problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File choose context info problem


  • Subject: Re: File choose context info problem
  • From: Shaun Wexler <email@hidden>
  • Date: Mon, 15 Aug 2005 12:12:59 -0700

On Aug 15, 2005, at 10:57 AM, <email@hidden> <email@hidden> wrote:

In my application I have two different buttons each activating a single
file chooser method. I have set the button tags to 0 and 1. In the file
chooser I have attempted to pass [NSNumber numberWithInt:[sender tag]]
as the contextInfo parameter, but when it gets to the
chooserFinished:returnCode:contextInfo method it crashes the application
in Mac os 10.3.9 and below.
It works in 10.4x though.
I must not understand what the contextInfo parameter is for. I thought
since it was a void pointer you could pass anything to it. Can some one
help shed some light on this for me?

If you pass an object as a void*, make sure to retain it. You are using a factory method, which autoreleases its objects. The callback is handled asynchronously, so the main runloop will dispose of all autoreleased objects before you receive the callback. You must release the object in the callback, if applicable. First of all, use [[NSNumber allocWithZone:NULL] initWithInt:[sender tag]]. You can also cast the int tag to a pointer type and don't need to wrap it with an object, to pass the value. I believe you can even get away with a different method signature on the callback method, to avoid casting the tag again...
--
Shaun Wexler
MacFOH
http://www.macfoh.com



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: File choose context info problem
      • From: <email@hidden>
References: 
 >File choose context info problem (From: <email@hidden>)

  • Prev by Date: Re: NEWBIE: Connecting up all those Ms, Vs and Cs
  • Next by Date: Re: coredata during startup
  • Previous by thread: File choose context info problem
  • Next by thread: Re: File choose context info problem
  • Index(es):
    • Date
    • Thread