------- iOS training, Android training, Java training , and looking forward to communicating with you! ----------
The role of 1.import
Impor is the import of external files or frameworks, as in the Include feature, but the advantage of import is that it prevents duplicate imports.
2. Speaking of object-oriented, object-oriented features, say the object-oriented: Object-oriented OOP, in solving the problem we only care about the tool to solve this method, that is, the object, do not care about the process of solving this method. Features: There are three characteristics: encapsulation: Encapsulation is to prevent the outside world directly access or modify the object's member variables, improve program security. Inheritance: Subclasses inherit the parent class, and the child class fully owns the member variable or method of the parent class. Reduces the amount of code and improves the connection between classes. Polymorphism: A variety of forms of something, such as a subclass method that can be called by a parent class. Reduces the amount of code and improves productivity.
The difference between the 3.OC method and the C function
The 1>oc method is owned by the object, and the C function is owned by the entire program. The 2>oc method can access the member variables of the object, and the C function cannot access the member variables. The 3> function cannot be written between the @interface and the @end. The difference between the 4.OC object method and the OC class method The 1> object method begins with-the class method begins with A +. The 2> object method can access member variables, and class methods cannot access member variables. The 3> object method is called by the object, and the class method is called by the class. 4> object methods can pass parameters, and class methods cannot pass parameters.
The use of 5.self and super
Self is a pointer to the caller of the method, and if the object is called, it points to the object, and if it is a class call, the pointer to class super is called the Parent class method, which is typically used to preserve certain methods when overriding the parent class method.
6. Scope of member variables
@private: Represents a member variable that can only be accessed directly by the current class. @protected: Represents a member variable that can be accessed directly by the current class or subclass, which is the default property. @public: Represents a member variable that can be accessed directly from anywhere. @package: Represents member variables that can be accessed directly within the same frame.
7. Overriding the role of the description method
Change the format that NSLog displays on the screen. -description default is the class name: Memory address display +description default is displayed in the class name.
8. Say the universal pointer, dot syntax
Universal pointer: Is the ID, it can point to any object, equivalent to NSObject * Point syntax: is the member variable setter and the Getter method shorthand. If you assign a value through point syntax, it is the setter method, which is the Getter method if you return a value through the point syntax.
[email protected] and @synthesize usage
@property:1> can automatically declare setter and Getter methods for member variables. The setter and getter methods of variables can also be implemented automatically after XCODE4.5. 2> can automatically generate a member variable (eg:_age) with an underscore _ Plus member variable name, and the type is @private. 3> @property is used in header files. @synthesize:1> can automatically implement the setter and getter methods of member variables. 2> can automatically generate member variable names (eg:age), and the type is @private. 3> @synthesize is used in. m files. Division of 10..h and. m files
. h: This file is what methods and member variables are declared: This file is a method of implementing a variable.
11. Memory management scope, principle, principle, where is embodied
Administrative scope: All objects that inherit nsobject. Principle: By referencing whether the counter is 0, if the reference counter of an object is 0, then this object has been recycled, otherwise it is not recycled principle:1> if anyone wants to use an object, then the object needs to be retain. 2> If someone wants to release an object, they need to do a release operation on the image. 3> who retain, who release, who Alloc, who release. Embodies:1> @perproty parameters, with retain, assign and copy. Retain and copy reference counter +1 to the object; 2>autorelease aspect. A release operation is performed on all objects in the object pool.
What are the parameters of [email protected] and what are their roles?
Set memory management: Retain: Release the old value and retain the new value. Assign: Description does not require memory management, direct assignment copy:release old value, copy new value. Whether setter and Getter methods are required: Readwrite: Setter and Getter methods are required. Readonly: Just need getter method. Method name aspect: Setter = method name. Set Setter Method Name getter = Method name. To set the Getter method name Multithreading: nonatomic: No multi-threading, high performance. Atomic: Use multi-threading for low performance. The role, benefits, and attention of 13.autorelease
function:1> all objects into the auto-release pool. 2> when the pool is destroyed, a release operation is performed on all objects in the pool. 3> will return the object itself. 4> does not affect object reference counters. Benefit:1> does not need to care about object release time. 2> does not need to care when to use release. Note:1> If the program consumes large memory, autorelease is not used. 2> if the program consumes less memory, the use of autorelease has little effect.
14. What is a classification (category)? What is the difference between classification and inheritance?
Classification: The classification is to add methods to the original class without changing the original class member variables and methods. The difference between classification and inheritance: The 1> classification can only add methods, cannot increase member variables, inheritance is a subclass of a member variable and method that completely owns the parent class, and it can also add its own member variables and methods on the basis of the parent class. 2> Classification Method Name if it is the same as the method name of the original class, the method of classification overrides the method in the original class. The method name in the inherited child class cannot be the same as the method name in the parent class.
15. Say what is the Protocol (protocol)? And the two keywords in the agreement?
Protocol is used to declare a variety of methods, so that other classes can be called at any time, improve program writing efficiency. @required: This method must be implemented and a warning will be issued if not implemented. @optional: This means that the method can be implemented or not implemented.
16. Explain your understanding of the agency
Definition: Provides a proxy for other objects to control this object. Eg: Xiao Ming didn't want to cook, so he asked for a babysitter, but the babysitter needed to sign an agreement, and the nanny had to abide by the agreement. So the nanny is the agent, the agent needs to abide by an agreement. Condition: If you want to be a proxy, you must adhere to a protocol (the protocol is used to declare methods, and the proxy must have a method). Action: You can listen to whether a method is triggered. Advantages: Low coupling, increased flexibility of the code. Eg: the agent was deleted, but the person is still there. The agent and the object do not affect each other. What is the difference between 17.block and function?
Function: block for saving a piece of code, easy to call the program at any time with the function of the same point:1> has a return value 2> both tangible parameters 3> Call method same 4> can save code and function different points: 1>blok's flag is ^, and function does not 2>block The local variable value cannot be modified by default, the function can. 3> in block case, when the statement ends, you need to add a semicolon outside the curly brace, and the function does not need it.
[email protected] What's the difference with #import
1> @class just declare a class in the. h file and do not know the member variables and methods of this class. #import可以被导入文件的所有信息, including member variables and methods. 2> when using @class, if you import hundreds of files at the same time, once the imported files have changed, you only need to change the header file, do not need to recompile, high efficiency. If you use #import, you need to recompile for less efficiency. 3> If you need to call member variables and methods of a class in a. m file, you need to #import import.
19. What are the commonly used structures?
Nsrange: Indicates the range. Nspoint/cgpoint: Represents the point location Nssize/cgsize: Represents the size of the UI Nsrect/cgrect: Indicates the location and size of the UI
20 Common classes and collections
Common classes: Nsstring/nsmutablestring collection: Nsarry/nsmutabarry (ordered), Nsset/nsmutableset, Nsdictonary/nsmutabledictonary, NSDate , NSObject
What is the difference between 21.copy and retain?
In case of a shallow copy: copy is retain. In the case of deep copy: Copy produces a new object, the source object reference timer is unchanged, and the copy counter is incremented by 1.
22. How many ways to traverse a collection? Say it separately.
There are three ways of traversing: method one: Normal traversal:
1 for (int i=0; i<array.count;i++) 2 { 3 NSLog (@ "%@", Array[i]); 4 }
Method Two: Fast traversal
1 for (ID in array) 2 { 3 NSLog (@ "%@", obj); 4
Method Three: Block traversal
1 [Array Enumerateobjectsusingblock:2^(IDObj,nsuinteger idx, Boolbool *stop)3 { 4NSLog (@"index =%d, element =%@", Idx,obj); 5 if(idx =0) 6 { 7*stop = YES;//Stop Traversal8 } 9} ];
The difference between 23.NSValue and NSNumber 1>nsnumber is a subclass of Nsvalue. 2>nsnumber can only wrap basic data types, while nsvalue may wrap arbitrary types, such as characters, arrays, structs, and so on.
Dark Horse Programmer-oc Summary