Skip navigation.
 
mlRe: NSToolbarItem action problem
FROM : Sherm Pendley
DATE : Mon Nov 22 22:52:09 2004

On Nov 22, 2004, at 4:44 PM, <email_removed> wrote:

> I have a class that when initialized, creates an NSMutableArray. At
> this point, it is valid. I set that class as the target for a
> NSToolbarItem. Then i set the action to one of its methods define as
> "-(void) doAction:(id)sender". When the NSToolbarItem is pressed, the
> action method gets called and goes through fine. As soon as i try and
> access any of my instances array data, i crash. Can i access my
> instances data when im in an action like this? I checked it out, and
> all my instances data is invalid only when im in an action. Whats
> going on here?


How are you creating your array? If you're using one of the
"convenience" class methods such as +arrayWithObjects, you'll get an
autoreleased object. If that's what you're doing, you'll need to
explicitly retain the array since you want to keep it for later.

For an excellent discussion of memory management in Cocoa, see the
"Hold me, use me, free me" article on Stepwise:

<http://www.stepwise.com/Articles/Technical/HoldMe.html>

sherm--

Related mailsAuthorDate
mlNSToolbarItem action problem alex Nov 22, 22:44
mlRe: NSToolbarItem action problem Sherm Pendley Nov 22, 22:52