Learning Object-C from scratch --- the fourth day, object-c --- the fourth day
Today, we will mainly explain how to use the data types and expressions of Object-C, four basic data types of Object-C: int, float, double, char
1.int type
There are two special formats in Object-C:
1. if the first integer is 0, the integer is expressed in octal notation. For example, 050 indicates 40 in decimal format (0*64 + 5*8 + 0*1 = 40 ), output in NSLog () is as follows: (% I is output in decimal format, % o is output in octal format but leading 0 is not output, % # o is output in octal format including leading 0)
# Import <Foundation/Foundation. h> int main (int argc, const char * argv []) {@ autoreleasepool {int a = 050; NSLog (@ "% I", ); NSLog (@ "% o", a); NSLog (@ "% # o", a);} return 0;} output result: 01:27:37. 752 Demo2 [685: 29598] 402014-10-30 01:27:37. 753 Demo2 [685: 29598] 502014-10-30 01:27:37. 753 Demo2 [685: 29598] 050 Program ended with exit code: 0
2. if the integer is 0 or x (both uppercase and lowercase), the integer is expressed in hexadecimal notation (note: the hexadecimal number consists of 0-9 numbers and letters between a and f (or a to F), where the A-F represents the number 10-15), such as 0xFFEF0D output is as follows:
# Import <Foundation/Foundation. h> int main (int argc, const char * argv []) {@ autoreleasepool {int B = 0xFFEF0D; NSLog (@ "% I", B ); NSLog (@ "% x", B); NSLog (@ "% # x", B);} return 0;} output result: 01:37:35. 516 Demo2 [702: 32548] 167728772014-10-30 01:37:35. 516 Demo2 [702: 32548] ffef0d2014-10-30 01:37:35. 516 Demo2 [702: 32548] 0xffef0d
How to Learn the object-c Language
Single inheritance: Objective-C does not support multiple inheritance (same as Java and Smalltalk), while C ++ supports multiple inheritance. Dynamic: Objective-C is dynamicaly typed, so its class library is easier to operate than C ++. Objective-C allows access to methods and classes based on string names at runtime, and supports dynamic connection and addition of classes. C ++ follows the Simula 67 (an early OO language) School in object-oriented programming, while Objecive-C belongs to the Smalltalk School.
With the foundation of JAVA object-oriented language, learning OBJ-C is also easy.
We hope that you can learn your thoughts first and then grasp the syntax or usage to learn and use all the computer languages.
How to Learn object-c
Buy this document. It would be easier if you have learned java. Fuel