宏定义 #define
定义形式 #define 标识符 字符串
含参数的 #define a(b) 2*b;
当需要参数拼接时 用## #define FunctionTest(a) -(void)te##a{NSLog(@"test");}
需要换行时 用\ #define str(a,b,c) {a+=b;a+=c;}
#define str(a,b,c) {a+=b;\
a+=c;}
// // SynthesizeSingleton.h // CocoaWithLove // // Created by Matt Gallagher on 20/10/08. // Copyright 2009 Matt Gallagher. All rights reserved. // // Permission is given to use this source code file without charge in any // project, commercial or otherwise, entirely at your risk, with the condition // that any redistribution (in part or whole) of source code must retain // this copyright and permission notice. Attribution in compiled projects is // appreciated but not required. // #define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \ \ static classname *shared##classname = nil; \ \ + (classname *)shared##classname \ { \ @synchronized(self) \ { \ if (shared##classname == nil) \ { \ shared##classname = [[self alloc] init]; \ } \ } \ \ return shared##classname; \ } \ \ + (id)allocWithZone:(NSZone *)zone \ { \ @synchronized(self) \ { \ if (shared##classname == nil) \ { \ shared##classname = [super allocWithZone:zone]; \ return shared##classname; \ } \ } \ \ return nil; \ } \ \ - (id)copyWithZone:(NSZone *)zone \ { \ return self; \ } \ \
浙公网安备 33010602011771号