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
#include <stdio.h> | |
#define stringify(VALUE) # VALUE | |
enum { | |
DERP, | |
DERRRRP | |
}; | |
int main(void) { | |
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
#pragma mark - Utilities | |
/*! Returns the major version of iOS, for iOS 6.1.3 it returns 6. | |
*/ | |
NSUInteger DeviceSystemMajorVersion() | |
{ | |
static NSUInteger _deviceSystemMajorVersion = -1; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
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
+ (UIImage*)imageWithSize:(CGSize)size color:(UIColor*)color | |
{ | |
UIView *view = [[UIView alloc] initWithSize:size]; | |
view.backgroundColor = color; | |
UIGraphicsBeginImageContextWithOptions(size, YES, 0); | |
CGContextTranslateCTM(UIGraphicsGetCurrentContext(), 0, 0); | |
[[view layer] renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
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 _UIBackdropEffectView : UIView | |
{ | |
CABackdropLayer *_backdropLayer; | |
float _zoom; | |
} | |
+ (Class)layerClass; | |
@property(nonatomic) float zoom; // @synthesize zoom=_zoom; | |
@property(retain, nonatomic) CABackdropLayer *backdropLayer; // @synthesize backdropLayer=_backdropLayer; | |
- (void)backdropLayerStatisticsDidChange:(id)arg1; |
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 _UIBackdropEffectView : UIView | |
{ | |
CABackdropLayer *_backdropLayer; | |
float _zoom; | |
} | |
+ (Class)layerClass; | |
@property(nonatomic) float zoom; // @synthesize zoom=_zoom; | |
@property(retain, nonatomic) CABackdropLayer *backdropLayer; // @synthesize backdropLayer=_backdropLayer; | |
- (void)backdropLayerStatisticsDidChange:(id)arg1; |
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
NSString *str = @"http://example.com/å.png"; | |
NSURL *url = [NSURL URLWithString:str]; | |
NSLog(@"%@",url); // NOPE! | |
NSString *str = @"http://example.com/å.png"; | |
str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
NSURL *url = [NSURL URLWithString:str]; | |
NSLog(@"%@",url); // YUP! |
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
@implementation UICollectionView (TEST) | |
-(void)setContentSize:(CGSize)contentSize | |
{ | |
[super setContentSize:contentSize]; | |
NSLog(@"%@",NSStringFromCGSize(contentSize)); | |
} | |
@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
UIBackgroundTaskIdentifier taskId = [[UIApplication sharedApplication] | |
beginBackgroundTaskWithExpirationHandler:^{ | |
}]; | |
/// Do something... | |
double delayInSeconds = 3.0; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); |
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 DrawStringInRect(NSString *string, CGRect rect, UIFont *font, NSTextAlignment alignment, UIColor *color) | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
if (context == NULL) return; | |
NSRange range = NSMakeRange(0, string.length); | |
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string]; | |
NSMutableDictionary *attributes = [NSMutableDictionary dictionary]; | |
NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; |
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
+ (NSString *) ipsum:(NSUInteger) numberOfParagraphs | |
{ | |
NSString *urlString = [NSString stringWithFormat:@"http://loripsum.net/api/%0d/short/prude/plaintext", numberOfParagraphs]; | |
NSError *error; | |
NSString *string = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString] encoding:NSUTF8StringEncoding error:&error]; | |
if (!string) | |
{ | |
NSLog(@"Error: %@", error.localizedDescription); | |
return nil; |