单例模式
来源:互联网 发布:java同步锁和互斥锁 编辑:程序博客网 时间:2024/05/23 12:02
单例模式
- #import <Foundation/Foundation.h>
- @interface TCUtil : NSObject {
- BOOL isOpenedOfPanel_;
- }
- @property (nonatomic, assign) BOOL isOpenedOfPanel;
- // Singleton stuff
- + (TCUtil *)sharedUtilInstance;
- @end
- //
- // TCUtil.m
- // TrendsCity
- //
- // Copyright 2011 卓文华讯. All rights reserved.
- //
- #import "TCUtil.h"
- #import <QuartzCore/QuartzCore.h>
- @implementation TCUtil
- @synthesize isOpenedOfPanel = isOpenedOfPanel_;
- #pragma mark -
- #pragma mark Singleton stuff
- static TCUtil *utilInstance_ = nil;
- + (TCUtil *)sharedUtilInstance {
- if (!utilInstance_) {
- utilInstance_ = [[self alloc] init];
- }
- return utilInstance_;
- }
- + (id)alloc {
- NSAssert(utilInstance_ == nil, @"Attempted to allocate a second instance of a singleton.");
- return [super alloc];
- }
- - (id)init {
- self = [super init];
- if (self) {
- isOpenedOfPanel_ = NO;
- }
- return self;
- }
- #pragma mark -
- #pragma mark Memory management methods
- - (void)dealloc {
- [utilInstance_ release];
- utilInstance_ = nil;
- [super dealloc];
- }
- @end
- 单例、单例模式
- 单例模式-多线程单例模式
- 单件模式(单例模式)
- 设计模式------单例模式
- 设计模式------单例模式
- 设计模式-单例模式
- 设计模式 - 单例模式
- 设计模式---单例模式
- 设计模式---单例模式
- PHP模式-单例模式
- 【设计模式】单例模式
- 设计模式-单例模式
- 设计模式----单例模式
- 设计模式--单例模式
- 设计模式-单例模式
- 单例模式(单子模式)
- 设计模式-单例模式
- [设计模式] 单例模式
- C#各种时间格式化/C#日期格式化
- Microsoft Script editor 安装步骤
- DSP市场拓展纵横谈(从TI官网转载的,觉得挺不错的)
- 因数数量奇偶
- 求crc的calcrc函数
- 单例模式
- 培养孩子必做的三件事
- Assigning the return value of new by reference is deprecated in xxxx
- SQLserver锁和事务隔离级别的比较与使用
- 使用strcpy的几点心得
- 安装交叉编译工具链
- Android错误:unable to find explicit activity class
- struts2+spring+iBatis集成
- js添加删除行