Class instantiation and method call in oc, oc instance call
In the previous article, we talked about the creation of oop and classes. In the previous article, we will review this article to implement class instantiation and call public parameters and methods in the class. The implementation of the class is in. in the m file, the following is the implementation code:
/// HuiTu. m // Test // Created by Cheng Ying on. // Copyright, 2017, Cheng yingmiao. all rights reserved. // # import "HuiTu. h "@ implementation HuiTu // obtain the color-(void) GetYanse :( NSString *) yanse {_ yanse = yanse; NSLog (@" % @ ", _ yanse );} // obtain the shape-(void) GetXingZhuang :( NSString *) xingzhuang {_ xingzhuang = xingzhuang; NSLog (@ "% @", _ xingzhuang );}; // draw-(void) HuiZhi {NSLog (@ "Start Drw ");//...} @ end
Next we will go to main. call the huitu class in m: The Code is as follows: add reference # import "HuiTu. h "main {HuiTu * h = [[HuiTu alloc] init]; // The instantiation class * Pointer Points to the class [h GetYanse: @" red "]; [h HuiZhi];}