NSLog(@"문자열출력"); /* 문자열출력 */
NSString *const MyFirstConstant = @"FirstConstant";
NSLog(@"This is the %@", MyFirstConstant); /* This is the FirstConstant */
@"문자열"
의 형식으로 출력한다@" "
안에 알맞는 서식 지정자를 넣어줘야 한다C언어의 서식 지정자란:
컴퓨터가 어떤 정보를 어떻게 해석할 것인지 지정히고, 형식(데이터 타입)이 정해진 정보를 문자 형식으로 재해석한다. (서식 지정자 리스트)
%d
10진수로 출력%o
8진수로 출력%x
16진수로 출력%f
소수 출력 소수점 자리수를 지정하려면 %.자릿수f%c
문자 (Character) 출력%@
객체 출력
int i = 1234;
int j = -23;
NSLog(@"%d와 %d을 출력합니다.", i, j); /* 1234와 -23을 출력합니다. */
#import <Foundation/Foundation.h>
int main() {
NSAutoreleasePool *pool = [NSAutoreleasePool alloc] init];
NSLog(@"Hello World"); /* hello world */
[pool drain];
return 0;
}
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *const string = @"hello world";
printf("%s", [string UTF8String]);
[pool drain];
return 0;
}