First, the program source code in C language as an example, how to convert to machine executable code?
Answer:
C Source code---preprocessor--compiler- --assembler----Convert to executable file
1. C source code through the preprocessor the result, or C language
2. Preprocessor is compiled (syntax, Word sense analysis, code optimization, code generation), the result is assembly code
3. Assembler code passes the assembler the result is an intermediate code (. O), which is essentially a binary code
4. The intermediate file (. o) is linked to the linker and the executable file is finally generated.
Second, C language more flexible piece of content is the pointer, then please talk about your understanding of the pointer.
the idea of answering this question:
1. What is a pointer, the basic concept of pointers
2, the use of the pointer to the scene
3, combined with specific examples of how the pointer can solve what problems
4. Questions about pointer arithmetic
three, C language memory layout
1, Code area: the main storage code, that is, the program instructions, the data is read-only.
2. Data area: Initialized zone and uninitialized zone. When declaring a global variable, the value is given at the same time, and the variable is placed in the initialized area. Uninitialized zone: BBS, the variable of this area, by default, all initially zero.
3. Heap area: The area where the programmer touches the most, the malloc function allocates memory from this area, which expands from bottom to top.
4, the stack area: by the system to manage the memory area, local variables and functions also exist in this area, characterized by advanced.
5. Command parameters and environment variable area
understanding of the Const keyword in C language
A, for the modification of non-pointer variables, the const int myint is the same as the Int const myint expression, which means that Myint is a constant. The value of the Myint cannot be modified. It is recommended to use the const int MYINT.
b, for the declaration of pointer variables, there are four cases, take int* as an example:
1, const int *pmypointer
2, int const *pmypointer
3, int * Const *pmypointer
4, const int * Const PMYPOINTER
for 1, 22 cases, the meaning of the expression is the same, all refers to the pointer to the content can not be modified.
in the 3rd case, the meaning of the expression is that the pointer itself cannot point to another address.
for the 4th case, the content that the pointer is pointing to cannot be modified, and the pointer itself cannot point to another address.
Five, in the inheritance grammar, about OC's method dispatch mechanism
1. Each object has a pointer to its class
2. When sending a message to an object, when the object is ready to execute the method, it will first find the method in the class of the current object, if it is found, start execution, if not found, go to the object belongs to the class of the parent class to find, if found to execute, if not found, Will go up and down the inheritance chain one layer at a time, until the NSObject class, if found to execute, if not found, the compiler will first give a warning, if this warning is ignored, the program will crash at run time.
vi. in inheritance, how do the child class objects use the member variables declared by the parent class?
when a new class is created, its object first inherits the member variable from the parent class and then adds its own member variable.
What about your understanding of self and super in OC?
1.self First he was a pointer.
2. When a message is sent to an object, when the object calls the corresponding method, in the calling method, in this method, a pointer is hidden, and the pointer is self, and the self represents the receiver of the message that called the method.
3. Sometimes, we need to explicitly call the parent's method in the subclass, this time super can represent the parent class, it should be noted that this super is not a pointer, not a member variable, but it is only the compiler recognized instructions, mainly for subclasses to access the content of the parent class.
What is the difference between the "header.h" and the #include ?
1, #include belongs to the preprocessing instructions. The main function is to import all the contents of the header file, the essence is to copy the contents of the header file to the implementation file (. C. M. cpp. mm)
2. The functionality and nature of #import与 # include are the same.
3. #include "header.h" enclosed in double quotes. Because to import the contents of the header file, you need to find the location of the header file, for double quotation marks, the preprocessor will first from the current project path down to find the corresponding header file, if not found, go to the System header file directory lookup.
4. #include <> angle brackets, the preprocessor will find the location of the header file directly from the system header file directory
5. #include "" is typically used to import custom header files. #include <> is mainly used to import the system header files, then the # include preprocessing directives, when the file is interdependent, prone to repeated errors, in order to solve this problem, C language introduced the head file guard mechanism #ifndef # Define #endif.
6. #import主要的特点是, it is not necessary to use the head file defender to achieve the non-duplicate include header file. In essence, his content has solved the problem of repeated inclusion, so in the OC language, we mainly recommend the use of #import
Nine, talk about your understanding of OC programming language memory management mechanism.
1. Each object has an integer associated with it, and we call this integer a reference counter or a retention-remembering device
2, when a piece of code or an object, you need to access this object, the reference counter of this object will be added 1.
10, what is the automatic release of the pool, what is the mechanism?
An auto-release pool is like a container (a stack-like data structure), when an object is not sure when it is destroyed, or when it is destroyed, the code implementation becomes more complex, and then a autorelease message can be sent to the object, then the object will be placed in the auto-release pool. When the auto-release pool is destroyed, a release message is sent to all objects in the pool to ensure that the object memory is destroyed, then the automatic free pool destruction is regular and is usually destroyed and created after an event loop is automatically completed.
* Try not to use the auto-release pool in iphone app development.
11. What are the rules for manually managing memory?
1. If you create an object, you must take into account that you want to dispose of the object. If you use new, Alloc, and the Copy method obtains an object, you must either release or automatically dispose of the object.
2. If a retain message is sent to the created object, the release message must be sent to this object to ensure that the retain and release are used the same number of times. 3. In view of the particularity of the new, Alloc, copy method, so the general method in our program, do not use this three keyword beginning, unless our method is also to create the object.
12, the role of the category
1. Add a new behavior for an existing class (not necessarily a custom class, or a system-defined class, or a third-party-provided class) 2. The implementation of classes (complex, larger projects) can be dispersed into different files, or different frameworks can be implemented
3. You can create a forward reference to a private method (typically, do jailbreak development often uses this feature)
4. You can create a nsobject category, (add an informal agreement to an object)
There are two limitations of the category
1. Unable to add new instance variable to category, category has no location to hold instance variable
2. The name conflict category has a higher priority.
This article is from the "8697643" blog, please be sure to keep this source http://8707643.blog.51cto.com/8697643/1630514
iOS Learning Notes