• 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: Dynamic Method Creation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Dynamic Method Creation
      • From: Jean Suisse <email@hidden>
References: 
 >Dynamic Method Creation (From: Steve Steinitz <email@hidden>)
 >Re: Dynamic Method Creation (From: Ken Thomases <email@hidden>)
 >Re: Dynamic Method Creation (From: Steve Steinitz <email@hidden>)
 >Re: Dynamic Method Creation (From: Jean Suisse <email@hidden>)

  • Prev by Date: Re: Dynamic Method Creation
  • Next by Date: Re: NSColor contrasting color?
  • Previous by thread: Re: Dynamic Method Creation
  • Next by thread: Re: Dynamic Method Creation
  • Index(es):
    • Date
    • Thread