Prefix.pch

1 기본값[ | ]

//
// Prefix header for all source files of the '프로젝트명' target in the '프로젝트명' project
//

#import <Availability.h>

#ifndef __IPHONE_4_0
#warning "This project uses features only available in iOS SDK 4.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif

2 추가[ | ]

// 변수 할당 축약형
#define DIC1(obj1,key1)	[NSDictionary dictionaryWithObjectsAndKeys:obj1,key1,nil]
#define DIC2(obj1,key1,obj2,key2)	[NSDictionary dictionaryWithObjectsAndKeys:obj1,key1,obj2,key2,nil]

#define IMG(x)	[UIImage imageNamed:x]

#define MP3(x)	[[NSBundle mainBundle] pathForResource:x ofType:@"mp3"]
#define WAV(x)	[[NSBundle mainBundle] pathForResource:x ofType:@"wav"]
#define PNG(x)	[[NSBundle mainBundle] pathForResource:x ofType:@"png"]
#define JPG(x)	[[NSBundle mainBundle] pathForResource:x ofType:@"jpg"]

// 형변환
#define INT2NUM(x)	[NSNumber numberWithInt:(x)]
#define FLT2NUM(x)	[NSNumber numberWithFloat:(x)]
#define STR2DAT(x)	[x dataUsingEncoding: NSUTF8StringEncoding]
// 배열
#define ArrayLength(x)	(sizeof(x)/sizeof((x)))

// 그래픽
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

// 사용자 정의 변수
#define UDInt(x)	[[NSUserDefaults standardUserDefaults] integerForKey:x]
#define UDBool(x)	[[NSUserDefaults standardUserDefaults] boolForKey:x]
#define UDFloat(x)	[[NSUserDefaults standardUserDefaults] floatForKey:x]
#define UDDouble(x)	[[NSUserDefaults standardUserDefaults] doubleForKey:x]

#define UDSetInt(x,y)	[[NSUserDefaults standardUserDefaults] setInteger:x forKey:y]
#define UDSetBool(x,y)	[[NSUserDefaults standardUserDefaults] setBool:x forKey:y];
#define UDSetFloat(x,y)	[[NSUserDefaults standardUserDefaults] setFloat:x forKey:y]
#define UDSetDouble(x,y)	[[NSUserDefaults standardUserDefaults] setDouble:x forKey:y]
#define UDSync()	[[NSUserDefaults standardUserDefaults] synchronize]

//NOTIFICATION
#define NotiAdd(x)	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onNoti:) name:x object:nil]
#define NotiCall(name,obj)	[[NSNotificationCenter defaultCenter] postNotificationName:name object:self userInfo:obj]

//SQL
#define SQLCountQuery(x)	[SQL countQuery:x]
#define SQLCountQuery1(x,a)	[SQL countQuery:[NSString stringWithFormat:x,a]]
#define SQLCountQuery2(x,a,b)	[SQL countQuery:[NSString stringWithFormat:x,a,b]]
#define SQLCountQuery3(x,a,b,c)	[SQL countQuery:[NSString stringWithFormat:x,a,b,c]]
#define SQLCountQuery4(x,a,b,c,d)	[SQL countQuery:[NSString stringWithFormat:x,a,b,c,d]]
#define SQLCountQuery5(x,a,b,c,d,e)	[SQL countQuery:[NSString stringWithFormat:x,a,b,c,d,e]]

#define SQLQuery(x)	[SQL query:x]
#define SQLQuery1(x,a)	[SQL query:[NSString stringWithFormat:x,a]]
#define SQLQuery2(x,a,b)	[SQL query:[NSString stringWithFormat:x,a,b]]
#define SQLQuery3(x,a,b,c)	[SQL query:[NSString stringWithFormat:x,a,b,c]]
#define SQLQuery4(x,a,b,c,d)	[SQL query:[NSString stringWithFormat:x,a,b,c,d]]
#define SQLQuery5(x,a,b,c,d,e)	[SQL query:[NSString stringWithFormat:x,a,b,c,d,e]]
#define SQLQuery6(x,a,b,c,d,e,f)	[SQL query:[NSString stringWithFormat:x,a,b,c,d,e,f]]

//equivalent funciton for PHP
#define explode(delimiter,string)	[string componentsSeparatedByString:delimiter]

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}