------------------------静态数据成员节省空间------------
如果类的不同对象共用同一的对象、值,可以把它写成静态全局对象形式,而不用每个实例对象都创建一遍共用的值。例如:
//不同的tableviewCell根据不同值显示不同图片,标签,uiimage可以写成静态数据成员形式
static NSString *today;
static NSString *tomorrow;
static NSString *yesterday;
static UIImage *q1Image;
static UIImage *q2Image;
static UIImage *q3Image;
static UIImage *q4Image;
+ (void)initialize {
// Unlikely to have any subclasses, but check class nevertheless
if (self == [APLTimeZoneWrapper class]) {
today = NSLocalizedString(@"Today", "Today");
tomorrow = NSLocalizedString(@"Tomorrow", "Tomorrow");
yesterday = NSLocalizedString(@"Yesterday", "Yesterday");
q1Image = [UIImage imageNamed:@"12-6AM.png"];
q2Image = [UIImage imageNamed:@"6-12AM.png"];
q3Image = [UIImage imageNamed:@"12-6PM.png"];
q4Image = [UIImage imageNamed:@"6-12PM.png"];
}
}