2012-05-19 32 views

回答

4
NSString *temp = @".";  
NSLog(@"%@", temp); 

的NSLog格式說明:

%@ Object, calls the Object's description method 
%d, %i signed int 
%u unsigned int 
%f float/double 
%p for pointers to show the memory address 
%zu value of type size_t (for sizeof(variable function) 
%s C strings 
\u can used for arbitrary unicode chars example:NSLog(@"\u03c0");//π 
3

的Objective-C並沒有真正擁有自己的專用打印功能。 NSLog將打印你給出的一些調試信息。對於直接打印,C printf()基本上仍然是標準。作爲您的代碼的等價物,我會寫:

NSString *temp = @"."; 
printf("%s\n", [temp UTF8String]); 
相關問題