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;

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容