//点击(button)领取的时间,
-(void)receiveCoin
{
self.coinStateLabel.text = @"招财币已领取";
self.coinBtn.userInteractionEnabled = NO;
NSDate *now = [NSDate new];
unsigned units = NSMonthCalendarUnit|NSDayCalendarUnit|NSYearCalendarUnit;
NSCalendar *mCal = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *mComp = [mCal components:units fromDate:now];
NSDate *mDate = [mCal dateFromComponents:mComp];
NSTimeInterval timeInterval = [mDate timeIntervalSince1970];
NSUserDefaults *dateDefault = [NSUserDefaultsstandardUserDefaults];
[dateDefault setValue:[NSString stringWithFormat:@"%f",timeInterval] forKey:@"dateFlag"];
}
//进入页面的时间
-(BOOL)isReceiveCoin
{
NSDate *now = [NSDate new];
unsigned units = NSMonthCalendarUnit|NSDayCalendarUnit|NSYearCalendarUnit;
NSCalendar *mCal = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *mComp = [mCal components:units fromDate:now];
NSDate *mDate = [mCal dateFromComponents:mComp];
NSTimeInterval timeInterval = [mDate timeIntervalSince1970];
NSUserDefaults *dateDefault = [NSUserDefaultsstandardUserDefaults];
float mInterval = [[dateDefault valueForKey:@"dateFlag"]floatValue];
if(timeInterval - mInterval >= 24 * 60 * 60 - 1){
return NO;
}else{
return YES;
}
}