iOS方法调用

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 ([self rankString].count - 1);

}

下面方法可以执行

NSObject+xxx.h

@interface NSObject (xxx)

- (void)test;

@end


NSObject+xxx.m

@implementation NSObject (xxx)

- (void)test {
 
}

@end


Person.h

@interface Person : NSObject

@end


Person.m

#import "NSObject+xxx.h"

@implementation Person

+ (void)doSomething {
 [self test];
}

@end

你可能感兴趣的:(iOS方法调用)