Re: NSAlert strategy advice
Re: NSAlert strategy advice
- Subject: Re: NSAlert strategy advice
- From: Bruce Truax <email@hidden>
- Date: Sat, 18 Dec 2004 22:10:11 -0500
I guess it depends on how much work you need to do to respond to the alert.
If each alert requires a similar set of instructions it seems like a waste
of code to rewrite it in each method. For example in one application I need
to call an NSOpenPanel from 4 different places in the same object to get 4
different file names. I use one openPanelDidEnd method and pass the pointer
to the string which gets the name as the contextInfo. I can then put the
file name into the proper NSString or in this case I check which object
pointer the context info equals and then I can set the string and update the
user defaults with two lines of code for each file. If the methods were
longer then I agree, I would pass the selector for the method and have the
panelDidEnd function pass off control to the appropriate method.
Bruce
On 12/18/04 6:17 PM, "Andreas Mayer" <email@hidden> eloquently wrote:
>
> Am 18.12.2004 um 23:04 Uhr schrieb Bruce Truax:
>
>> If you define the integer values with
>> #define statements in your file then the switch statement can be easy
>> to
>> read and self documenting.
>
> That's not a very object oriented solution.
>
> Why not pass a selector (or maybe a selector name) and call that? No
> switch needed and therefore no changes necessary when adding alerts
> (and corresponding selectors).
>
>
> Andreas
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden