iOS-正确的model创建姿势

#import@interface DYServiceAPIConfig : NSObject

+ (instancetype) shared;

@property (nonatomic, readonly) NSArray *newsInfoArray;

@end


+ (instancetype)shared

{

static DYServiceAPIConfig *_instance = nil;

static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

_instance = [[self alloc] init];

});

return _instance;

}



- (instancetype)init

{

self = [super init];

if (self) {

_newsInfoArray = @[@{ @"topId" : @"",

@"title" : @"头条"},

@{ @"topId" : @"T1461396384709",

@"title" : @"网游"},

@{ @"topId" : @"T1461396358842",

@"title" : @"手游"},

@{ @"topId" : @"T1461396291717",

@"title" : @"主机"},

@{ @"topId" : @"T1461396413033",

@"title" : @"电竞"},

@{ @"topId" : @"T1461396489605",

@"title" : @"暴雪"}];

}

return self;

}

你可能感兴趣的:(iOS-正确的model创建姿势)