• 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: Kyle Sluder <email@hidden>
  • Date: Tue, 20 Sep 2011 15:58:44 -0700

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

  • Follow-Ups:
    • Re: Telling apart different save panels
      • From: Graham Cox <email@hidden>
References: 
 >Telling apart different save panels (From: Graham Cox <email@hidden>)

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