share a set of previously learned data from iOS development, followed by a continuous update :
OC Data Type
Data type: base data type, pointer data type
Basic data types: numeric, character (char), Boolean, NULL type (void)
Pointer data type: class, ID
Numeric type: integer type int, float float, double
C and the OC the basic data type
int: Declaring an integer variable
Double: Declaring a two-precision variable
float: Declaring floating-point variables
Char: Declaring a character-type variable
ID: Generic pointer type
Enum: declaring enum type
Long: Declares a variable or function of length integer
Short: Declaring a variable or function with a shorter integer
Signed: Declaring a signed type variable
struct: Declaring struct-body variables
Union: Declaring a common body (union) data type
Unsigned: Declaring an unsigned type variable
void: Declares a function with no return value or no parameter
Data type formatting specifier
Data type OC keyword format description boot character
integer int%d.%i
Short int%hd.%hi
Long, type long int%ld.%li
Unsigned short-integer unsigned int%u
No short integral type unsigned shorter%hu
unsigned long integer unsigned%lu
Float type float%f
Double-%f
Long Double%LF
Character Char-%c
Specific data types
Integer type
The integer type in OC is represented by an int, and the formatted symbol is represented by%i or%d.
For example: int a=100;
The integer constant of the OC language defaults to int, declaring that a long constant can be followed by an "L" or "L", such as:
int B=600;//long c=888888888l;
Type occupies a storage space domain value range
Byte 1 bytes-128-127
Short 2 bytes -2′15-2′15-1
int 4 bytes -2′31-2′31-1
A long 8 byte -2′63-2′63-1
Note: 2 ' 63 is 2 of the 63-time Square
Floating-point types
Variables of floating-point types can store values that include decimals
There are two types of floating-point in OC
float valid numbers for 6-7-bit format notation symbols with%f
double valid numbers are 15-16-bit format notation symbols expressed in%f.%e or%g
The floating-point constant in OC defaults to double, and if you want to declare a constant of float, add F or F after the number
For example: double m=3.14159;//correctly float f=3.14f;
Type occupies a storage space domain value range
Float 4 byte -3.403E38
Double 8 byte -1.798e308-1.798e
string Char
Char data is used to denote "characters" in the usual sense, and the format specifier is expressed in%c
Character constants are single characters enclosed in single quotes,
Example: Char achar= ' a '; char b= ' 0 '; char cchar= ' Apple '; Range: 128-127
"\ n", the OC compiler considers this as a single character
unsigned char domain range: 0~255
The OC characters are Unicode encoded and each character occupies two bytes, so it can be represented in hexadecimal notation.
For example: Char c1= ' \u0061 ';
Note: Unicode is a unified global language encoding
Logic Type Boolean ( boolean )
A Boolean type is a variable used to store true and false values, and is typically used for program flow control.
Boolean data allows for a value of true or FALSE, or an integer of 0 or not 0 instead of true and false, which differs from the Java language.
Instance:
Boolean Flag=true
if (flag)
{
NSLog (@ "Hello iphone");
}
Qualifying words
long int: Declare variable xx as a long integer variable, formatted symbol is ¥%LI, such as: Long int A;
Long Long int: declaration variable xx is a long long integer variable, the format symbol bit%lli, such as: long long int b;
long double: basically the same as int;
unsigned int: declares an unsigned integer variable, such as: unsigned int c;
signed Int: Declares a signed integer variable. such as: Signed int d.
void type (empty type)
Tells the compiler that there are no values of range types
You cannot declare a variable like any other data type
Example: void i=10;//error
Void is usually used in conjunction with methods such as:
-(void) test
{
Code
}
ID type
The ID type is a unique data type in OC that can store any type of object, and in a sense it is a generic object type.
• Declare number as a variable of type ID,
such as: ID number;
• Format specifier:%p
iOS Development-oc Language (i) OC data type