IOS network with multithreaded--7. Performselector Message processing methods

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.