//
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)