This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define IS_IOS_7 ([[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."][0] intValue] >= 7) | |
#define API_RQST_TIME_OUT 30 | |
// part of header file -------------------------------------------------------- | |
#import <Foundation/Foundation.h> | |
@protocol API_Handler <NSObject> | |
@required | |
- (void)didSuccess:(NSData*)data; | |
- (void)didFail:(NSError*)error; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f | |
typedef NS_ENUM(NSInteger, DeviceType) { | |
DeviceType_iPhone3Gs, | |
DeviceType_iPhone4_4s, | |
DeviceType_iPhone5, | |
}; | |
- (DeviceType)getTypeOfDevice { | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString*)UDID { | |
NSString *uuidString = nil; | |
// get os version | |
NSUInteger currentOSVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]; | |
if(currentOSVersion <= 5) { | |
if([[NSUserDefaults standardUserDefaults] valueForKey:@"udid"]) { | |
uuidString = [[NSUserDefaults standardDefaults] valueForKey:@"udid"]; | |
} else { | |
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDate *)lastWeek { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day-7; | |
[comp setHour:0]; | |
[comp setMinute:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSDate *)yesterday { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day-1; | |
[comp setHour:0]; | |
[comp setMinute:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSDate *)firstDateForLastMonth { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month-1; | |
comp.year = comp.year; | |
comp.day = 1; | |
[comp setHour:0]; | |
[comp setMinute:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDate*)remove24HoursToDate:(NSDate*)date { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:date]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day; | |
[comp setHour:0]; | |
[comp setMinute:0]; | |
[comp setSecond:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add 23:59:59 hours to - (assume today is 30-Jul-2013) example range yesterday = 29-Jul-2013 12:00:00 AM + "to" + 30-Jul-2013 23:59:59 PM | |
- (NSDate*)add24HoursToDate:(NSDate*)date { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:date]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day; | |
[comp setHour:23]; | |
[comp setMinute:59]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDate*) currentDate_midnightTime { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month; | |
comp.year = comp.year; | |
comp.day = comp.day; | |
[comp setHour:0]; | |
[comp setMinute:0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDate*)twoMonthspastDate { | |
NSCalendar *cal = [NSCalendar currentCalendar]; | |
NSDate *now = [NSDate date]; | |
NSDateComponents *comp = [cal components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:now]; | |
comp.timeZone=[NSTimeZone defaultTimeZone]; | |
comp.month = comp.month-2; | |
comp.year = comp.year; | |
comp.day = 1; | |
[comp setHour:0]; | |
[comp setMinute:0]; |