viewcontroller.m// oc High Efficiency 52 for multiple use type constants, less # define preprocessing directives/** * 1. do not define constants with preprocessing. The defined constants do not contain type information, and the compiler simply performs a find-and-replace operation on this basis before compiling. Immediately someone redefined the constant value, and the compiler does not produce a warning message, which causes the constant values in the application to be inconsistent. 2. Use static const in the implementation file to define constants that are visible only within the compilation unit. Because such constants are not in the global symbol table, you do not need to prefix their names. 3. use extern in the header file to declare the global variable and define its value in the relevant implementation file. This constant is to appear in the global symbol list, so its name should be separated, usually prefixed with the class name associated with it. */#import "ViewController.h" #define animation_durtion 0.3 //defined constants, no type information static const nstimeinterval kanimationduration = 2.0;//know that constant types help write development documents//variables must be used static const to declare that if the view modifies the variable declared by the const, the compiler will error @interface viewcontroller () @endNSString *const eocloginmanagerdidloginnotificaton = @ "Eocloginmanagerdidloginnotificaton"; @implementation viewcontroller-(void) animate{ [uiview animatewithduration:kanimationduration Animations:^{ //perform animations; uiview *view = [[uiview alloc]initwithframe:cgrectmake (100, 100,  80, 80)]; view.backgroundcolor = [uicolor orangeColor]; [self.view addSubview:view]; } completion:^ (bool finished) { }];} - (void) viewdidload { [super viewdidload]; // Do any additional setup after loading the view, typically from a nib. [self animate];// [self login]; uibutton *btn = [[uibutton alloc]initwithframe:cgrectmake (150, 300, 100, 30)]; btn.backgroundcolor = [uicolor Greencolor]; [btn addtarget:self action: @selector (login) forcontrolevents:uicontroleventtouchdraginside]; [btn settitle:@ "Click Notifications" FORSTATE:UICONTROLSTATENORMAL];    [SELF.VIEW ADDSUBVIEW:BTN];} -(void) Login{ [[nsnotificationcenter defaultcenter]postnotificationname: eocloginmanagerdidloginnotificaton object:nil]; }- (void) didreceivememorywarning { [super didreceivememorywarning]; // dispose of any resources that can be recreated.} @end
OC High Efficiency 52 multi-use type constants, less # define preprocessing directives