SEL数据类型

时间:2023-03-09 17:02:31
SEL数据类型

SEL数据类型

//

//  main.m

//  06-SEL数据类型

//

//  Created by apple on 14-3-18.

//  Copyright (c) 2014年 apple. All rights reserved.

//

#import <Foundation/Foundation.h>

/*

SEL数据类型是用来包装方法的

*/

#import "Person.h"

int main(int argc, const char * argv[])

{

@autoreleasepool {

Person * p = [[Person alloc] init];

//消息机制

//        [p eat];

/*

//使用@selector就能够把一个方法包装成 SEL数据类型

SEL s1 = @selector(eat);

[p performSelector:s1];

SEL s2 = @selector(call:);

[p performSelector:s2 withObject:@"135047654"];

SEL s3 = @selector(findName);

NSString * str = [p performSelector:s3];

NSLog(@"%@",str);

*/

//        [p performSelector:@selector(eat)];

[p performSelector:@selector(abc)];

[p eat];

}

return 0;

}