//
//  timeForButtonCount.m
//  Open
//
//  Created by 看看智能 on 2017/2/27.
//  Copyright © 2017年 黄江涛 . All rights reserved.
//

#import "timeForButtonCount.h"

@implementation timeForButtonCount
-(void)methodWithTimeCount:(UIButton *)button
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
                dispatch_async(dispatch_get_main_queue(), ^{
        self.timeCount = KKNumber;
        button.userInteractionEnabled =YES;
        self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(reduceTime:) userInfo:button repeats:YES];
                    
    });
    });

}
-(void)reduceTime:(NSTimer*)timer
{
    self.timeCount--;
  
    if (self.timeCount == 0) {

        UIButton *info = timer.userInfo;
        info.enabled = YES;
        info.userInteractionEnabled =YES;
        [self.timer invalidate];

    }else
    {
        UIButton *info = timer.userInfo;
        info.userInteractionEnabled =NO;
    }



}
-(instancetype)initMustTakeReturn:(UIButton*)returnCode
{
    self = [super init];
    if (self) {
        self.timeCount =0 ;
        self.timer =[NSTimer new];
    }
    return self;
    
}
@end
