类别
来源:互联网 发布:网络购物案列分析 编辑:程序博客网 时间:2024/04/28 05:06
该类有十个方法,利用分类的形式,将这十个方法分类别进行管理,并实现调用
#import <Foundation/Foundation.h>
@interface Student : NSObject
@property(nonatomic,retain)NSString *name;
@end
@interface Student (study)
-(void)studyMath;
-(void)studyEnglish;
-(void)studyChinese;
@end
@interface Student (eat)
-(void)eatApple;
-(void)eatBanana;
-(void)eatPear;
@end
@interface Student (play)
-(void)playSoccer;
-(void)playBasketball;
-(void)playGuitar;
-(void)playPiano;
@end
#import "Student.h"
@implementation Student
-(void)studyMath
{
NSLog(@"studyMath");
}
-(void)studyEnglish
{
NSLog(@"studyEnglish");
}
-(void)studyChinese
{
NSLog(@"studyChinese");
}
-(void)eatApple
{
NSLog(@"eatApple");
}
-(void)eatBanana
{
NSLog(@"eatBanana");
}
-(void)eatPear
{
NSLog(@"eatPear");
}
-(void)playSoccer
{
NSLog(@"playSoccer");
}
-(void)playBasketball
{
NSLog(@"playBasketball");
}
-(void)playGuitar
{
NSLog(@"playGuitar");
}
-(void)playPiano
{
NSLog(@"playPiano");
}
@end
#import <Foundation/Foundation.h>
#import "Student.h"
int main(int argc,const char * argv[])
{
@autoreleasepool {
Student *stu=[[Studentalloc]init];
[stu setName:@"Tiffany"];
[stu studyMath];
[stu studyEnglish];
[stu studyChinese];
[stu eatApple];
[stu eatBanana];
[stu eatPear];
[stu playSoccer];
[stu playBasketball];
[stu playGuitar];
[stu playPiano];
NSLog(@"%@",stu);
}
return 0;
}
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别
- 类别相关 匿名类别
- 服务器类别
- 实验类别
- Swift IOS8
- 适配器模式
- Varnish解决带参数的URL可能造成多份缓存的问题
- IEnumerable和IQueryable的那点事
- 没有Project Facets的解决方法
- 类别
- Varnish3.0中文入门教程
- (2)android之fill_parent,wrap_content,match_parent
- 1秒的价值:来自谷歌的统计数据:网页加载超过4秒,25%的人会放弃;手机网页超过10秒,50%用户会放弃,60%的人不会再返回该网站
- Varnish 3.x Cacti 监控插件
- AUTOSAR members
- meclipse中project facet问题
- 程序员的无奈(一):放下手术刀的抉择
- Does Razor support elseif?