Before discovering the details of the knowledge forgotten a lot, so from now on to the previous knowledge to comb, starting from OC
I. Language points of OC
Hyper-set of 1.c languages, allowing C language source code in OC, compiler compatible with C language Program
2. Have perfect object-oriented features
3. Includes a runtime system
4. Class Library Rich
Two. Object-oriented Programming
1. Object-oriented programming OOP (Object Oriented programming)
2. Object-Oriented programming is: c++,java,c#
3. Concepts: Objects, classes, encapsulation, inheritance, combinations, etc...
Note:
Two kinds of programming ideas
1. Process-oriented programming: Analyze the steps to solve the problem, implement the function, and call it sequentially.
2. Object-Oriented programming: The decomposition of the object of the problem, the coordination between the objects and communication. Solve the problem
3. The object defines the behavior in the steps to resolve the problem and does not deliberately complete a step.
4. Process-centric, object-centric
5. Object-oriented design with good scalability and reusability
Three. Classes and objects
1. Classes and objects are the object-oriented core
2. Define the class, create the object, and use the object.
3. A class is an abstraction of something with the same characteristics and behavior
4. Object is an instance of a class
5. Class is the type of object
Four. Definitions of classes in OC
1. Using object completion programs in object-oriented programming
2. In development, first define the class, after creating the object, use
3. The definition class is divided into two steps: the interface part and the implementation part. Do not separate
A. Interface part: The characteristics and behavior of the foreign declaration class;
B. Realization part: Internal realization behavior;
Interface section
1. Logo of the interface section: @[email protected]
2. Role: declaring instance variables and methods of a class, i.e. behavior and characteristics
3. Include content: class, parent class name, instance variable, method
Implementation part
1. Implement part mark: @[email protected]
2. Role: Implementation method, that is, the implementation of class behavior
Classes and files
1. Class: @[email protected] @[email protected]
2. File:. h is called an interface file,. m is called an implementation file. The default settings are as follows
A. Naming a file with a class name
B.. h the interface portion of the file management class, the implementation part of the. m File Management class
3. File and class are not intrinsically related, for ease of management, implementation of encapsulation features
Five. Create an Object
1. Create objects in two steps: allocating memory space and initializing
2. Allocating memory space: allocating memory for an object based on an instance variable declared in the class
3. Initialize: Initialize the instance variable to the created object
+ (ID) alloc; + indicates that this method belongs to a class, can only be executed by class, ID represents an object of any type, that is, a good object is created
-(ID) alloc; -Indicates that this method belongs to an object, only the object executes, and the ID represents the object that the initialization completed
Note:
1. The pointer stores the object's first address, which refers to the object. Working with pointer objects in OC
2.Person *p = [person all]; Execute the right side of the equals sign first;
The [person all] return value is the object's first address, which is the object.
P is a pointer variable of the same type as the object, storing the object's first address, representing the object
3. Instance variables are not equal to objects
The grammatical basis of OC (i)