Re: Dynamic Method Creation
Re: Dynamic Method Creation
- Subject: Re: Dynamic Method Creation
- From: Steve Steinitz <email@hidden>
- Date: Sat, 15 Sep 2012 19:11:56 +1000
Hi Jean,
On 15 Sep 12, at 6:12pm, Jean Suisse wrote:
> 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.
Yes, that was intentional, just for this purpose :)
> 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);
> etc.
Wow! Is it really that simple? Thank you Jean, you have saved the day.
> You will probably want two sets of macro :
> DECLARE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
> SYTNHESIZE_WHATEVER_BUNCH_OF_FUNCTION_FOR_DAY(dayName)
Right, one for the .h and one for the .m. Good point.
Thanks again, Jean.
All the best,
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