DATA Types
Objective supports all data type which are in c.
Similar to c (bool) Objective C has extra data type is BOOL used specially in COCOA.
BOOL is typedefed to signed char . which require 8 bit to store. Some time in c non zero value is consider as true so here take care if u are assigning nonzero value say 0x1230 to BOOL it will get last byte which is zero (means False or NO value).
BOOL use YES which is #defined to 1 and NO which is #defined to 0. Take care this condition also when programing comparing YES with non zero number.
Here imp is Non Zero value is not same as YES. (in c non zero is true ).
So to avoid this Its better to compare with NO (zero value) is always safe.
Forma Specifier
Objective c uses the same format specifier as the c .
There is one addition format specifier for displaying object details :- %@
when u pass %@ and object to NSLog . NSLog calls description() method of that object which returns object details in NSString format.
XCode shortcut:- to run app use ⌘⇧R.
Objective supports all data type which are in c.
Similar to c (bool) Objective C has extra data type is BOOL used specially in COCOA.
BOOL is typedefed to signed char . which require 8 bit to store. Some time in c non zero value is consider as true so here take care if u are assigning nonzero value say 0x1230 to BOOL it will get last byte which is zero (means False or NO value).
BOOL use YES which is #defined to 1 and NO which is #defined to 0. Take care this condition also when programing comparing YES with non zero number.
Here imp is Non Zero value is not same as YES. (in c non zero is true ).
So to avoid this Its better to compare with NO (zero value) is always safe.
Forma Specifier
Objective c uses the same format specifier as the c .
There is one addition format specifier for displaying object details :- %@
when u pass %@ and object to NSLog . NSLog calls description() method of that object which returns object details in NSString format.
XCode shortcut:- to run app use ⌘⇧R.
%@
|
For any object
|
---|---|
%%
|
Writes a % character.
|
%d,%D
|
signed 32-bit integer
|
%u or %U
|
unsigned 32-bit integer
|
%x
|
signed int as a hexadecimal character
|
%X
|
unsigned int as a hexadecimal character
|
%o,%O
|
an unsigned 32-bit int in octal format.
|
%f
|
double value (64-bit floating-point number)
|
%e
|
64-bit floating-point double value in exponent format.
|
%E
|
64-bit floating-point double value in uppercase exponent format.
|
%g
|
double (64 bit floating point) in the %e format when the exponent is less than -4 or if greater or equal to the precision as %f.
|
%G
|
As the %g format but in uppercase (E).
|
%c
|
Output an unsigned char
|
%C
|
unsigned 16-bit unichar character.
|
%s
|
Outputs an 8 bit null terminated unsigned character.
|
%S
|
Unicode null terminted characters.
|
%p
|
void* pointer in hexadecimal format
|
%a
|
double also known as a 64-bit floating-point number.
|
%A
|
as above but the exponential symbol is in uppercase.
|
%F
|
double in decimal notation
|