Get updates on your email

Thursday, January 7, 2016

Minus 1 Day from Week, 5 Days from Month and 1 Month from Year Time Interval Using NSDateFormatter

-(BOOL)weeklyCheck:(NSString *)dayLabel{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"EEEE"];
    NSDate *now = [NSDate date];
    NSDate *newDate1 = [now dateByAddingTimeInterval:60*60*24*-1];
    NSString *currentDay = [dateFormatter stringFromDate:newDate1];
    NSLog(@"%@, %@",currentDay,dayLabel);
    if ([dayLabel isEqualToString:currentDay]) {
        NSLog(@"Yup Working");
        return YES;
    else return NO;

Wednesday, January 6, 2016

Check if a Credit/Debit Card is about to expire or has expired iOS

I came across applying this logic in an app which was quite simple but took me sometime to figure out as I'm a mid-level iOS developer.
Problem is to check whether a credit card is about to expire or has expired. So how to do it?

Solution is very simple we will use NSDateFormatter and play along with it.