#import "ApiService.h"
@implementation ApiService
static ApiService *sharedInstance = nil;
+ (ApiService *)sharedInstance
{
if (sharedInstance == nil)
{
sharedInstance = [[self alloc]init];
}
return sharedInstance;
}
- (id)init
{
if (self = [super init])
{
}
return self;
}
@end
当我打电话给+sharedInstance
self 指的是什么?如何允许从 Class 方法调用 init?