Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore
#define SYNTHESIZE_SINGLETON_FOR_CLASS(MySingleTonClassName)

static GameController *sharedGameController = nil; <===== (9)/QUOTE]

Can anyone please let me know , what is the exact requirement of the Macro, I mean what does it actually do at compile time..

Does it take care of having only one allocation of object over all the application code.

Thank you.
 

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore
Thanks for the reply,

#
define SYNTHESIZE_SINGLETON_FOR_CLASS(MySingleTonClassName)

To be clear what does the macro SYNTHESIZE_SINGLETON_FOR_CLASS(MySingleTonCassName) do exactly..
 

chown33

Moderator
Staff member
Aug 9, 2009
10,750
8,422
A sea of green
Thanks for the reply,

#

To be clear what does the macro SYNTHESIZE_SINGLETON_FOR_CLASS(MySingleTonCassName) do exactly..

Referring to this article:
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html

SYNTHESIZE_SINGLETON_FOR_CLASS is a multi-line macro. It expands to the series of \-delimited lines of code that you see in SynthesizeSingleton.h. Like any macro, it also replaces occurrences of its parameters (classname in the given header), with whatever you've entered between the parentheses.

If you don't know about \-delimited continuation lines, or don't understand macros in general, you should refer to a C reference book. Those things are plain standard C.

If you're asking "please explain all the code", then I think you can read the article and the code well enough to work that out yourself. If not, then you need to review the fundamentals.

If you have a specific question about a specific line of code in the expanded macro, then paste that line into a post.

Expecting someone to provide an exact line-by-line explanation of a 50-line macro is expecting too much, especially since there's an article that explains how to use it. The whole point of creating macros is that you don't have to understand what's inside them, all you have to do is use them correctly, and I think the article outlines the correct use.
 

mpramodjain

macrumors regular
Original poster
Nov 20, 2008
152
0
Banglore

Hi Chown,

Thanks for sharing the url.

After going through the url content (and SynthesizeSingleton.h file), I found that already I had implemented in my code (methods such as shared##classname etc) without using macro.So as per my little knowledge, I do think there would be no use to define macro as I am having only one singleton class all over the application.

Please suggest if am in wrong way.

Thanks for the reply.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.