Objective-C 静态方法可以重写吗

首先来看一段代码

#import 

@interface Person : NSObject

+ (void)pringName:(NSString *)name;

@end
#import "Person.h"

@interface Person()

@end

@implementation Person

+ (void)pringName:(NSString *)name
{
    NSLog(@"Person-%@",name);
}

@end
#import 
#import "Person.h"

@interface Student : Person

@end
#import "Student.h"

@implementation Student

+ (void)pringName:(NSString *)name
{
    NSLog(@"Student-%@",name);
}

@end
- (void)viewDidLoad {

    [Student pringName:@"小明"];
}
2018-03-13 09:18:06.371043+0800 DD[50663:8176634] Student-小明

从上面的打印信息可以看到静态方法是可以被重写的

你可能感兴趣的:(Objective-C 静态方法可以重写吗)