Create a Iosapp class
IOSApp.h file
1 #import<Foundation/Foundation.h>2 3 @interfaceIosapp:nsobject4 5 //1. Add a method with no parameters6-(void) printinfomation;7 8 //2. Add a method with parameters9-(void) Buyapp: (ID) AppName;Ten One @end
IOSAPP.M file
1 #import "IOSApp.h"2 3 @implementationIosapp4 5 //3. Implement a method without parameters in the header file6-(void) Printinfomation7 {8NSLog (@"Xcode Interactive Tutorials");9 }Ten One //4. Implement a method with parameters in the header file A-(void) Buyapp: (ID) AppName - { -NSLog (@"Buy the app%@", appName); the } - - @end
VIEWCONTROLLER.M file
1 #import "ViewController.h"2 //5. Import the header file of the class created by the steel3 #import "IOSApp.h"4 5 6 @interfaceViewcontroller ()7 8 @end9 Ten @implementationViewcontroller One A -- (void) Viewdidload { - [Super Viewdidload]; the //additional setup after loading the view, typically from a nib. - - //6. Initializing an object of a class -Iosapp *app =[[Iosapp alloc] init]; + //[email protected] () can be understood as the number of the class method, its behavior is basically equivalent to the C language function pointer, its result is the SEL type. -SEL method =@selector (printinfomation); + //The 8.respondsToSelector () method is used to determine if there is a method named in a given name. A if([app Respondstoselector:method]) { at - //9.performSelector is the runtime system is responsible for the method, at compile time do not do any check - //Calling Methods - [app Performselector:method]; - } - inSEL METHOD2 =@selector (Buyapp:); - if([app Respondstoselector:method2]) { to //Calling Methods +[App Performselector:method2 Withobject: (@"Photoshop Interactive Tutorials")]; - } the } * $ Panax Notoginseng -- (void) didreceivememorywarning { the [Super didreceivememorywarning]; + //Dispose of any resources the can be recreated. A } the + @end
IOS network with multithreaded--7. Performselector Message processing methods