Re: File choose context info problem
Re: File choose context info problem
- Subject: Re: File choose context info problem
- From: <email@hidden>
- Date: Mon, 15 Aug 2005 15:53:05 -0400
- Bounce-to: <email@hidden>
That must be it, I was not retaining the object. I should have thought
that through a little bit better. Thanks for the answer.
Mark.
On 8/15/2005, "Shaun Wexler" <email@hidden> wrote:
>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.co
_______________________________________________
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