Re: Dynamic Method Creation
Re: Dynamic Method Creation
- Subject: Re: Dynamic Method Creation
- From: Jean Suisse <email@hidden>
- Date: Sat, 15 Sep 2012 10:12:14 +0200
Hi Steve,
There seem to be a pattern in you methods: they all contain the name of a day of the week (monday) and you want them for all days. Then you could use macros.
Example :
#define SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName) \
- (Shift *) dayName##CreateShift { \
return [self createShiftForDayOfWeekNamed:[[self class] dayName##Name]]; \
} \
\
- (void) dayName##ClearShift { \
[self clearShiftForWeekdayNamed:[[self class] dayName##Name]]; \
}
Then, in your code, you will just need :
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(monday);
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(tuesday);
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(wednesday);
etc.
You will probably want two sets of macro :
DECLARE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
Cheers,
Jean
On 15 sept. 2012, at 07:49, Steve Steinitz wrote:
> Hi Ken,
>
> Thanks for your quick reply.
>
> On 15 Sep 12, at 3:16pm, Ken Thomases wrote:
>
>> No offense, but this seems like a terrible design. And your KVO hack method screams of papering over a bug.
>
> No offense but none of your criticisms seem to hold water. I might address them individually after I see if anyone can offer any help with my actual question, rather than cluttering the thread now.
>
> Cheers,
>
> Steve
_______________________________________________
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