//
//  YFTimerManager.h
//  Timer_Demo
//made in zhongdao  Copyright © 2018年 jianghu3. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YFTimer.h"

//.h文件
#define YFSingleTonH(ClassName)  +(instancetype)share##ClassName;

//.m文件
#define YFSingleTonM(ClassName) \
static id _instance=nil;\
+(instancetype)allocWithZone:(struct _NSZone *)zone{\
    static dispatch_once_t onceToken;\
    dispatch_once(&onceToken, ^{\
        _instance=[super allocWithZone:zone];\
    });\
    return _instance;\
}\
+(instancetype)share##ClassName{\
    static dispatch_once_t onceToken;\
    dispatch_once(&onceToken, ^{\
        _instance=[[self alloc] init];\
    });\
    return _instance;\
}\
-(instancetype)copyWithZone:(NSZone *)zone{\
    return _instance;\
}

@protocol YFTimerDelegate;

@interface YFTimerManager : NSObject

@property(nonatomic,strong)NSMutableArray *timers;

YFSingleTonH(YFTimerManager)

// 添加一个时间间隔是interval的定时器
+(void)addTimerWithTimeInterval:(NSTimeInterval)interval;

// 给时间间隔是interval的定时器设置代理
+(void)addTimerDelegate:(id<YFTimerDelegate>)delegate forTimeInterval:(NSTimeInterval)interval;

// 给时间间隔是interval的定时器取消代理
+(void)deleteTimerDelegate:(id<YFTimerDelegate>)delegate forTimeInterval:(NSTimeInterval)interval;

// 取消一个时间间隔是interval的定时器
+(void)invalidateTimerForTimeInterval:(NSTimeInterval)interval;

// 取消所有的定时器
+(void)invalidateAllTimer;

@end

