Effective Objective-C 2.0 Learning (1)

OC is a superset of the C language and uses object-oriented features. OC uses a message structure (messaging structure) instead of method calls (function calling), the difference is that the message structure determines the code to execute at runtime, while the method call is determined by the compiler.
OC uses a reference counting mechanism, and familiarity with C's memory model helps to understand OC's memory management.
Objects of OC are declared in the heap, written as: NSString *somgString = @"The string"; It is illegal to declare in the stack, NSString someString;
difference: the heap is generally allocated by the programmer, while The stack is allocated by the compiler.
The memory management of OC has been abstracted, called reference counting, and does not require the programmer to malloc and free.
Some OC variables (non-objects) use stack space, such as: CGRect, which is equivalent to a C structure. Because the objects that release OC are frequently created, it will affect performance.

Introducing as few other header files as possible in class header files can minimize compilation time and reduce mutual dependencies. In this case, use forward declaration.
In some cases, such as declaring conformance to a protocol, consider first moving these protocol declarations into the class-continuation category, and second or placing them in a separate protocol-only header file.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324689310&siteId=291194637