In objective-C, nslog is equivalent to printf in C language and is often used for text output.
Nslog Definition
Void nslog (nsstring * format ,...);
Basically, nslog is similar to printf and will also output the display result on the console. The difference is that the formatted characters passed in are nsstring objects, rather than char * string pointers.
Instance
Nslog can be used as follows:
Nslog (@ "this is a test ");
Nslog (@ "string is: % @", string );
Nslog (@ "x = % d, y = % d", 10, 20 );
However, the following statement cannot be used:
Int I = 12345;
Nslog (@ "% @", I );
The reason is that % @ needs to display the object, while int I is obviously not an object. to display the object correctly, write it:
Int I = 12345;
Nslog (@ "% d", I );
Format
The nslog format is as follows:
% @ Object
% D, % I integer
% U unsigned integer
% F floating point/double-Character
% X, % x binary integer
% O octal integer
% Zu size_t % P pointer
% E floating point/double-character (Scientific Computing)
% G floating point/double-Character
% S c string
%. * S Pascal string
% C characters
% C unicha
R % LLD 64-bit long integer
(Long) % LlU unsigned 64-bit long integer
% Lf 64-bit dual-Character