类方法中self的用法

来源:互联网 发布:制作传单的软件 编辑:程序博客网 时间:2024/06/04 23:26

If you are calling another class method from inside a class method (of the same class) you can just use [self classMethod]. If however you are in an instance method and you need to call that classes class method you can use [[self class] classMethod]



+ (NSArray *)rankString

{

    return@[@"?", @"A", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"J", @"Q", @"K"];

}


+ (NSUInteger)maxRank

{

return ([当前类rankString].count - 1);

    //用self也可以正常工作,比如return ([selfrankString].count -1);

}


0 0
原创粉丝点击