• 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: Telling apart different save panels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Telling apart different save panels


  • Subject: Re: Telling apart different save panels
  • From: Andy Lee <email@hidden>
  • Date: Tue, 20 Sep 2011 19:40:50 -0400

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 <email@hidden> 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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Telling apart different save panels (From: Graham Cox <email@hidden>)
 >Re: Telling apart different save panels (From: Kyle Sluder <email@hidden>)
 >Re: Telling apart different save panels (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Telling apart different save panels
  • Next by Date: FSCopyObjectAsync() under ARC
  • Previous by thread: Re: Telling apart different save panels
  • Next by thread: Re: Telling apart different save panels
  • Index(es):
    • Date
    • Thread