You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.8 KiB

//
// PPSingleton.h
// PPGetAddressBook
//
// Created by AndyPang on 16/9/19.
// Copyright © 2016年 AndyPang. All rights reserved.
//
/*
*********************************************************************************
*
* PP-iOS学习交流群: 323408051 !!!
*
* 使 PPGetAddressBook bug或有更好的建议,,
* bug,.
*
* Weibo : jkpang-
* Email : jkpang@outlook.com
* QQ : 323408051
* GitHub: https://github.com/jkpang
*
* PS:,使!
* 1.AFNetworking 3.x YYCache的二次封装,,FMDB:
* GitHub:https://github.com/jkpang/PPNetworkHelper
* 2.仿,,使:
* GitHub:https://github.com/jkpang/PPNumberButton
*
* PPGetAddressBook ,Star支持, !
*********************************************************************************
*/
#ifndef PPSingleton_h
#define PPSingleton_h
// .h文件
#define PPSingletonH(name) + (instancetype)shared##name;
// .m文件
#define PPSingletonM(name) \
static id _instance; \
\
+ (instancetype)allocWithZone:(struct _NSZone *)zone \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [super allocWithZone:zone]; \
}); \
return _instance; \
} \
\
+ (instancetype)shared##name \
{ \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_instance = [[self alloc] init]; \
}); \
return _instance; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return _instance; \
}
#endif /* PPSingleton_h */