Skip to content

NSLog

로그정보를 출력해주는 클래스이다. XCode의 Objective-C에서 사용 가능하다.

Example

NSLog를 DEBUG모드에서 동작하도록 설정하는 방법은 아래와 같다.1(추가적으로 로그를 출력하는 파일과 위치(라인)를 함께 출력한다)

#if defined( _DEBUG )
#  define  NSDLog( str, ... )  NSLog( @"<%@(%d)> %@", [[NSString stringWithUTF8String: __FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat: (str), ##__VA_ARGS__] )
#else
#  define  NSDLog( str, ... )
#endif

References


  1. 보통 *.pch파일에 정의해 놓는다.