People.h 文件
@interface People :NSObject{
int _age;
NSString * _name;
}
+(People*) peopleWithAge:(int)age andName:(NSStting*) name;
-(id) initWithAge:(int)age andName:(NSString) name;
-(int) getAge;
-(NSString*)getName;
@end
People.m
@implementation People
+(People) peopleWithAge:(int)age andName:(NSString*) name{
return [[People alloc] initWithAge:age andName:name];
}
-(instancetype) initWithAge:(int)age andName:(NSString*)name{
self =[init self];
if(self){
_age = age;
-Name= name;
}
return self;
}
-(int) getAge{
return _age;
}
-(NSString*)getName{
return _name;
}
@end