Small white Study Development (IOS) OC_ sel data type (2015-08-10)

Source: Internet
Author: User

//

Main.m

SEL Data Type

//

Created by admin on 15/8/12.

Copyright (c) years admin. All rights reserved.

//


#import <Foundation/Foundation.h>

#import "Person.h"

/*

SEL data type, so that the method used to wrap the

*/


int Main (int argc,const Char * argv[]) {

@autoreleasepool {

use @selector to wrap a method into a SEL data type

person *p = [[personalloc]init];

SEL s1 = @selector(EAT);

[Pperformselector: S1];

SEL s2 = @selector(call:);

[P performselector: S2withobject:@ "1519387554"];

SEL s3 = @selector(findName);

nsstring *result = [P performselector: S3];

NSLog (@ "%@", result);

}

return 0;

}

//

Person.h

the specific syntax of OC

//

Created by admin on 15/8/12.

Copyright (c) years admin. All rights reserved.

//


#import <Foundation/Foundation.h>


@interface Person:NSObject


-(void) eat;

-(void) Call: (nsstring *) number;

-(nsstring *) findName;

@end


//

Person.m

the specific syntax of OC

//

Created by admin on 15/8/12.

Copyright (c) years admin. All rights reserved.

//


#import "Person.h"


@implementation Person


-(void) eat

{

NSLog (@ " eat something ");

}

-(void) Call: (nsstring *) number

{

NSLog (@ " call %@", number);

}

-(nsstring *) findName

{

return@ " found Teng-gale ";

}

@end



Small white Study Development (IOS) OC_ sel data type (2015-08-10)

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.