// Person.h // ios初体验 // // Created by wjy0916 on 15/9/22. // Copyright (c) 2015年 ios. All rights reserved.
#import <Foundation/Foundation.h>
@interface Person : NSObject -(void) run; @end
// Person.m // ios初体验 // // Created by wjy0916 on 15/9/22. // Copyright (c) 2015年 ios. All rights reserved.
#import "Person.h"
@implementation Person -(void) run{
NSLog(@“Person——人在跑--------"); }
-(void)talk{
NSLog(@"talk+++++++++++++++++"); } @end
Teacher *t = [Teacher new]; SEL s1 = @selector(talk); BOOL b = [t respondsToSelector:s1]; NSLog(@“++++++++++++++%d",b);
Teacher 类中无任何代码,仅仅继承了,Person类 此时b = 1; 用t响应方法play是报错。
|