Things that are updated every day may have recurring content. At that time, each part of the knowledge point is different, we need to read carefully
The proper design of the iOS class is described here. Object Oriented thinking
Main.m
#import <Foundation/Foundation.h> #import "Iphone.h" int main (int argc, const char * argv[]) { Iphone * phone = [Ip Hone new]; Phone->_color = Iphonecolorwhite; Phone->_size = IPHONESIZE3POINT5; Phone = 0ffxxx //[0ffxxx camerawithflashlightstatus]; [Phone camerawithflashlightstatus:iphoneflashlightstatusopen]; return 0;}
Iphone.h
@interface iphone:nsobject{ @public /** used to store Iphone screen size * ///enum iphonesize and iphonesize equivalents Iphonesize _size;//used to store iphone screen size /** used to store iphone color */ iphonecolor _color;//used to store iphone color /** used to store CPU size */ float _cpu; /** used to store internal capacity */ float _ram;} Design techniques, if the method does not return value, do not tangle whether there is a return value, do not let trivial things interfere with the idea/** open flash */-(void) openflashlight;/** turn off Flash */-(void) closeflashlight;/** Own active */-(void) flaselightauto;/** photograph */-(void) Camerawithflashlightstatus: (iphoneflashlightstatus) Flaselightstatus; @end
Iphone.m
#import "Iphone.h" @implementation iphone/** open Flash */-(void) openflashlight{ NSLog (@ "Turn on Flash");} /** off Flash */-(void) closeflashlight{ NSLog (@ "Off Flash");} /** own initiative */-(void) flaselightauto{ NSLog (@ "own active mode");} /** photo */-(void) Camerawithflashlightstatus: (iphoneflashlightstatus) flaselightstatus{ //The inside of the class how to get an object address / /self keyword// who calls self on behalf of who if (flaselightstatus = = Iphoneflashlightstatusopen) { //open Flash [ Self openflashlight]; } else if (flaselightstatus = = Iphoneflashlightstatusclose) { [self closeflashlight]; Turn off the Flash } else { [self flaselightauto]; Own active mode } NSLog (@ "took photos.) Laugh a "); @end
The rational design of the iOS class, object-oriented thinking