Something about inheritance, I have two class here: female, the subclass of human, and human, it can run but showing issues.
Two issues here:
main.m:29:10: ‘human’ may not respond to ‘setSexy:’
main.m:30:10: ‘human’ may not respond to ‘isSexy’
main.m
#import <Foundation/Foundation.h>
#import "female.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
human *sexyGirl = [[female alloc] init];
[sexyGirl setName:@"SexyGirl"];
[sexyGirl setGender:0];
[sexyGirl setSexy:1];
[sexyGirl isSexy];
}
return 0;
}
female.h
#import "human.h"
@interface female : human {
BOOL sexy;
}
@property BOOL sexy;
-(void)isSexy;
@end
human.h
#import <Foundation/Foundation.h>
@interface human : NSObject {
NSInteger *hp;
NSString *name;
BOOL gender;
}
@property (assign, nonatomic) NSInteger *hp;
@property (assign, nonatomic) NSString *name;
@property (assign, nonatomic) BOOL gender;
-(void) walk;
@end
There is no method name
isSexyandsetSexyinhumanclassYou should change this
human *sexyGirl = [[female alloc] init];to this
female *sexyGirl = [[female alloc] init];