This file contains 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
+ (NSInteger)daysBetweenDate:(NSDate*)fromDateTime andDate:(NSDate*)toDateTime | |
{ | |
NSDate *fromDate; | |
NSDate *toDate; | |
NSCalendar *calendar = [NSCalendar currentCalendar]; | |
[calendar rangeOfUnit:NSDayCalendarUnit startDate:&fromDate | |
interval:NULL forDate:fromDateTime]; | |
[calendar rangeOfUnit:NSDayCalendarUnit startDate:&toDate |
This file contains 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
typedef NS_ENUM(NSInteger, UITableViewCellStyle) { | |
UITableViewCellStyleDefault, | |
UITableViewCellStyleValue1, | |
UITableViewCellStyleValue2, | |
UITableViewCellStyleSubtitle | |
}; |
This file contains 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
UIColor* color() | |
{ | |
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0 | |
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white | |
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black | |
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1]; | |
} |
This file contains 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
@interface UIColor (fromHex) | |
+ (UIColor *)colorwithHexString:(NSString *)hexStr alpha:(CGFloat)alpha; | |
@end |
This file contains 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
void PrintObjectMethods() { | |
unsigned int count = 0; | |
Method *methods = class_copyMethodList([NSObject class], &count); | |
for (unsigned int i = 0; i < count; ++i) { | |
SEL sel = method_getName(methods[i]); | |
const char *name = sel_getName(sel); | |
printf(“%s\n”, name); | |
} | |
free(methods); | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>People</key> | |
<array> | |
<string>😄</string> | |
<string>😃</string> | |
<string>😀</string> | |
<string>😊</string> |
This file contains 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
UIFont * GetVariationOfFontWithTrait(UIFont *baseFont, CTFontSymbolicTraits trait) { | |
CGFloat fontSize = [baseFont pointSize]; | |
CFStringRef baseFontName = (__bridge CFStringRef)[baseFont fontName]; | |
CTFontRef baseCTFont = CTFontCreateWithName(baseFontName, fontSize, NULL); | |
CTFontRef ctFont = CTFontCreateCopyWithSymbolicTraits(baseCTFont, 0, NULL, trait, trait); | |
NSString *variantFontName = CFBridgingRelease(CTFontCopyName(ctFont, kCTFontPostScriptNameKey)); | |
UIFont *variantFont = [UIFont fontWithName:variantFontName size:fontSize]; | |
CFRelease(ctFont); | |
CFRelease(baseCTFont); | |
return variationFont; |
This file contains 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
unsigned int countOfCores() { | |
unsigned int ncpu; | |
size_t len = sizeof(ncpu); | |
sysctlbyname(“hw.ncpu”, &ncpu, &len, NULL, 0); | |
return ncpu; | |
} |
This file contains 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
#import <QuartzCore/QuartzCore.h> | |
@interface CALayer (RNAnimations) | |
- (void)setValue:(id)value forKeyPath:(NSString *)keyPath duration:(CFTimeInterval)duration delay:(CFTimeInterval)delay; | |
@end |
This file contains 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_IPHONE_5 ([[UIScreen mainScreen] bounds].size.height == 568 ) | |
#define SYSTEM_VERSION ([[[UIDevice currentDevice] systemVersion] floatValue]) | |
#define IS_IOS7_ORLATER (SYSTEM_VERSION >= 7.0) | |
#define SYSTEM_CALL(TEL) ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", (TEL)]]]) | |
#define kAppDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate]) | |
#define NavigationBar_HEIGHT 44 | |
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width) | |
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height) |
NewerOlder