1. Create Class 2. Encapsulation class. h @interface (interface) 2.1 declares a member variable {variable list} 2.2 declares a function-(return type) method name: (parameter type) parameter 1 Label: (parameter type) parameter 2;. m @impleme Ntation (enable) Implementation function 3. Create an object using a class: class name * Object name = [[Class name alloc] init]; Alloc: class opens space init; object initialization @public//Common type access: both inside and outside of the class Member variables that can be accessed
@protected//Protected Access: A modified member variable that accesses access to the @private//private type in both the inside of the class and in the child class ... Member variables that are accessible only within the class #import <Foundation/Foundation.h> #import "Student.h"reference function to write header file#import"Game.h"
#import "Car.h"
/*
Introduce the header file: The difference between the left and # include is that import does not cause cross-compilation, and that the class you create is generally "" ... framework of the system with < >
*/
int main (int argc, const char * argv[])
{@autoreleasepool {//auto-free pool manages memory for user/*
Class name * object name; equal to int A;
NSString *[email protected] "Tom";//String plus * is Object-oriented NSString is a string class different from Char
NSLog (@ "name is a string:%@", name); The standard output function wraps automatically.
Nsarray *[email Protected][name,name,name];
NSLog (@ "Array is a array:%@", array);
For (NSString *str (self declared variable) in array)//loop traversal
{
NSLog (@ "For in%@", str);
}
*/
Obj-c class