On Dec 27, 2009, at 5:41 PM, Iceberg-Dev wrote:

> On Dec 27, 2009, at 11:48 PM, Graham Cox wrote:
> 
>> On 28/12/2009, at 9:40 AM, Iceberg-Dev wrote:
>> 
>>> Problem: what if you need to access the contextual info from the 
>>> panel:shouldShowFilename: method?
>>> 
>>> 
>>> I haven't found a method to access the contextual information in 
>>> NSSavePanel, NSPanel, NSWindow.
>> 
>> 
>> Typically the delegate is the controller that calls beginSheet... so 
>> whatever it passed as contextInfo is available to any delegate method 
>> because it's something internal to this controller object.
> 
> Can't disagree with that.
> 
>> If you've organised your code in such a way that the controller is not the 
>> delegate, you might want to reconsider that.
> 
> I could but isn't the purpose of a contextual info to be "contextual" and so 
> not attached to the controller instance?

The panel's delegate and its modalDelegate are two logically separate things 
(although you may choose to use the same object for both roles).  The 
modalDelegate is only messaged with the didEndSelector that you provide, and 
the contextInfo is passed as a parameter in that message.

Any of the delegate methods (as opposed to the modalDelegate method) are not 
provided the contextInfo.  The contextInfo is only relevant to the 
modalDelegate.  While you may use the controller that calls beginSheet:... as 
the delegate, you may also use a separate object that knows about a specific 
instance of the panel -- that is, you might wrap up the delegate behavior and 
what you're thinking of as context info into a class and pass an instance of 
that.  That allows a single controller to run multiple open panels 
simultaneously without crossing its wires (although I would probably recommend 
using a controller per instance).

Regards,
Ken

_______________________________________________

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