On 21/09/2011, at 8:54 AM, Scott Ribe wrote:

> Ah, I was thinking that the completion blocks were calling into the delegate, 
> and that you needed to distinguish between panels there. So you're trying to 
> distinguish earlier?


Yes, specifically, in the delegate method:

panel:validateURL:error:


Kyle's solution is working well for this situation. If it needed much more 
complexity I'd probably just move the whole task into the "helper" object, but 
this is fine for what I need. The only question remains whether  the memory 
management is safe - are there any circumstances where the completion block is 
NOT called? That's where I'm releasing the helper at the moment.

that is, my code looks like this:

        NSSavePanel*                            savePanel = [NSSavePanel 
savePanel];
        DKOTemplateSaverHelper*         helper = [[DKOTemplateSaverHelper 
alloc] initWithSavePanel:savePanel];
        
        void (^completionHandler)(NSInteger result) = ^(NSInteger result)
        {
                if( result == NSFileHandlingPanelOKButton )
                {
                        // perform the file saving task here
                }
                
                [helper release];
        };
        
        [savePanel beginSheetModalForWindow:[self windowForSheet] 
completionHandler:completionHandler];


where my helper retains the save panel, sets itself as its delegate, and also 
sets the panel's delegate to nil when its -dealloc method is called.


Thanks to others for the other suggestions about using the title and 
subclassing the panel - either will likely work, though the title solution 
seems a bit hackish, though I guess not too bad as the title is never displayed.




--Graham_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to