OC语言— super用法
2014-07-24 23:07
176 查看
/*
super
1、直接调用父类中的某个方法
2、super处在对象方法中,那么就会调用父类的对象方法
super处在类方法中,那么就会调用父类的类方法
3、使用场合:子类重写父类的方法时想保留父类的一些行为
*/
#include <Foundation/Foundation.h>
@interface Zoombie : NSObeject
- (void)walk;
+ (void)test;
- (void)test;
@end
@implementation Zoombie
- (void)walk
{
NSLog(@"往前跳下");
}
+ (void)test
{
NSLog(@"Zoombie+test");
}
- (void)test
{
NSLog(@"Zoombie-test");
}
@end
@interface JumpZoombie: Zoombie
+ (void)haha;
@end
@implementation JumpZoombie
+ (void)haha
{
[super test];
}
- (void)walk
{
NSLog(@"往前跳2下");
//直接调用父类的walk方法
[super walk];
//NSLog(@"往前跳下");
}
@end
int main()
{
[JumpZoombie haha];
// JumpZoombie *jz=[JumpZoombie new];
// [jz walk];
return 0;
}
super
1、直接调用父类中的某个方法
2、super处在对象方法中,那么就会调用父类的对象方法
super处在类方法中,那么就会调用父类的类方法
3、使用场合:子类重写父类的方法时想保留父类的一些行为
*/
#include <Foundation/Foundation.h>
@interface Zoombie : NSObeject
- (void)walk;
+ (void)test;
- (void)test;
@end
@implementation Zoombie
- (void)walk
{
NSLog(@"往前跳下");
}
+ (void)test
{
NSLog(@"Zoombie+test");
}
- (void)test
{
NSLog(@"Zoombie-test");
}
@end
@interface JumpZoombie: Zoombie
+ (void)haha;
@end
@implementation JumpZoombie
+ (void)haha
{
[super test];
}
- (void)walk
{
NSLog(@"往前跳2下");
//直接调用父类的walk方法
[super walk];
//NSLog(@"往前跳下");
}
@end
int main()
{
[JumpZoombie haha];
// JumpZoombie *jz=[JumpZoombie new];
// [jz walk];
return 0;
}
相关文章推荐
- OC语言-----NSString,NSMutableString基本用法
- 黑马程序员-OC语言中的两个关键字self和super
- 在OC中,super和self的用法
- 黑马程序员 《ios零基础教程》--OC语言三大特征及self和super 2014-4-25总结
- 黑马程序员-OC语言-关键字self与super
- 黑马程序员 - OC语言 - NSString的其他用法 (获取、转换、去掉)
- OC中description、 SEL、类本质、self和super用法
- 黑马程序员-[OC语言] 第六篇:foundation框架之 NSString 基本用法
- OC语言的第四天 static、self、super、继承、NSObject类、私有属性和私有方法、多态
- OC语言:类方法以及构造器与访问器的用法
- 黑马程序员—OC语言的self关键字和super关键字
- OC语言-----NSArray , NSMutableArray, NSNumber 基本用法
- 黑马程序员-OC语言-self和super关键字(听课笔记)
- OC语言中NSDate的用法
- oc语言学习之基础知识点介绍(四):方法的重写、多态以及self、super的介绍
- 第03天OC语言(10):super关键字
- 黑马程序员-OC语言-NSString 类介绍及用法(听课笔记)
- OC语言中NSDate的用法
- OC语言—self用法
- IOS开发---OC语言-⑨继承、组合、super