//
// TestTool.m
// test
//
// Created by point on 16/3/26.
// Copyright © 2016年 赵大财. All rights reserved.
//
#import "TestTool.h"
/**
*什么是静态变量? 需要一个数据为整类而非某个对象服务!
*静态变量优点?
*1:节省内存静态变量只存储一处 2:它的值是可以更新的
*/
static NSMutableDictionary *_zhaoDaCai;
@implementation TestTool
//方式1
+ (void)initialize
{
_zhaoDaCai = [NSMutableDictionary dictionary];
}
//方式2
+ (NSMutableDictionary *)zhaoDaCai
{
if (_zhaoDaCai == nil) {
_zhaoDaCai = [NSMutableDictionary dictionary];
}
return _zhaoDaCai;
}
+ (void)testToolAtcion {
NSLog(@"%@",_zhaoDaCai);
}
@end
转载于:https://my.oschina.net/zhaodacai/blog/647709