I guess I didn't understand the original problem. I thought the id of the save 
panel wasn't useful because it's local variable. It sounded like it's not so 
much the save panel you want to distinguish, but the context in which the save 
panel is being used. I was going to suggest making subclasses of NSSavePanel 
and using that to indicate context/purpose.

--Andy

On Sep 20, 2011, at 7:31 PM, Graham Cox wrote:

> OK, I've done it this way and it seems to be quite a nice solution - thanks!
> 
> In terms of memory management, I'm releasing the helper object (panel 
> delegate) in the completion block. While that apparently works without a 
> problem, I'm wondering if that's truly safe and reliable - I'm still fairly 
> new to blocks.
> 
> --Graham
> 
> 
> 
> 
> 
> On 21/09/2011, at 8:58 AM, Kyle Sluder wrote:
> 
>> On Tue, Sep 20, 2011 at 3:15 PM, Graham Cox <graham....@bigpond.com> wrote:
>>> I could of course assign the save panels to an ivar of the delegate so that 
>>> it can perform a comparison, but that strikes me as pretty messy, given 
>>> that otherwise the panels are very neatly encapsulated along with their 
>>> completion blocks. In addition, the delegate class is already complex and 
>>> broken up into multiple categories for ease of managing the code, and this 
>>> code lives in a category. Adding an ivar would need to be done in the main 
>>> class interface file and when you do that to support functionality in a 
>>> category, you get a warning from the analyser that the ivar is 'unused'.
>> 
>> Delegates often own the things that delegate to them. There's nothing
>> messy about this:
>> 
>> NSSavePanel *savePanel = [NSSavePanel savePanel];
>> MySavePanelDelegate *delegate = [[MySavePanelDelegate alloc] init];
>> [savePanel setDelegate:delegate]; // savePanel doesn't retain delegate
>> [delegate setSavePanel:savePanel]; // delegate retains savePanel
>> [savePanel beginWithCompletionHandler:^(NSInteger result){ /* ... */ }];
>> 
>> But perhaps an even better idea would be to factor out more of the
>> save-panel logic into that delegate object.
>> 
>> --Kyle Sluder
> 
> _______________________________________________
> 
> 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/aglee%40mac.com
> 
> This email sent to ag...@mac.com

_______________________________________________

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