1 Star 0 Fork 11

Mist/MayStall-ios

forked from KevinHM/MayStall-ios 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Singleton.m 1013 Bytes
一键复制 编辑 原始数据 按行查看 历史
//
// Singleton.m
// Fish
//
// Created by DAWEI FAN on 04/01/2014.
// Copyright (c) 2014 liqun. All rights reserved.
//
#import "Singleton.h"
@implementation Singleton
@synthesize string_select=string_select;
static Singleton * sharedSingleton = nil; //第一步:静态实例,并初始化。
+ (Singleton *) sharedInstance
{
if (sharedSingleton == nil) {
sharedSingleton = [[super allocWithZone:NULL] init];//第二步:实例构造检查静态实例是否为nil
}
return sharedSingleton;
}
+ (id) allocWithZone:(struct _NSZone *)zone//第三步:重写allocWithZone方法
{
return [[self sharedInstance] retain];
}
- (id) copyWithZone:(NSZone *) zone//第四步
{
return self;
}
- (id) retain
{
return self;
}
- (NSUInteger) retainCount
{
return NSUIntegerMax;
}
- (oneway void) release
{
}
- (id) autorelease
{
return self;
}
-(id)init
{
@synchronized(self) {
string_select=[[NSString alloc]init];
return self;
}
}
@end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mist/MayStall-ios.git
git@gitee.com:mist/MayStall-ios.git
mist
MayStall-ios
MayStall-ios
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385