main.m//10-the Declaration and implementation of the "Mastering" class//.h for the declaration of the class,. M is the implementation of the class, + represents the class method static method,-represents the object method. The methods in the. h file are public and cannot be changed. Access domain in Variable 3: public,protected (subclass), private (this class). #import <foundation/foundation.h>//declare the class @interface Person:nsobject (parent class name) { //Declare the attribute variable before you must underline it. NSString * _name; int _age; float _weight;} Declaration Method-(void) eat;-(void) run;+ (void) breath; @end//Make an implementation class for humans the class name of the class to implement which class is placed behind the @implementation. @implementation person//Implementation Method-(void) eat{ NSLog (@ "eat");} -(void) run{ NSLog (@ "Run and Run");} + (void) breath{ NSLog (@ "XXIXIXIXIX");} @endint Main (int argc, const char * argv[]) { @autoreleasepool { //Insert code here ... NSLog (@ "Hello, world!"); } return 0;}
Declaration and implementation of the Oc-04-class