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 <objc/runtime.h> | |
@implementation NSDictionary (Swizzled) | |
static void swizzInstance(Class class, SEL originalSel, SEL newSel) | |
{ | |
Method origMethod = class_getInstanceMethod(class, originalSel); | |
Method newMethod = class_getInstanceMethod(class, newSel); | |
method_exchangeImplementations(origMethod, newMethod); |
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
// | |
// SKValueObject.h | |
// TinyType | |
// | |
// Created by Soroush Khanlou on 5/15/14. | |
// Copyright (c) 2014 Soroush Khanlou. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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 <Foundation/Foundation.h> | |
int main (int argc, const char * argv[]) | |
{ | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
dateFormatter.dateFormat = @"YYYY"; | |
NSDate *date = [NSDate dateWithTimeIntervalSince1970:1419872056]; | |
NSLog (@"%@", [dateFormatter stringFromDate:date]); // 2015 | |
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
// CacheItem.h | |
@interface CacheItem : RLMObject | |
@property NSString *key; | |
@property NSData *value; | |
@end | |
// CacheItem.m | |
@implementation CacheItem |
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 UIStoryboard (Additions) | |
- (id __nullable)tryInstantiateViewControllerWithIdentifier:(NSString * __nonnull)identifier; | |
@end | |
@implementation UIStoryboard (Additions) | |
- (id)tryInstantiateViewControllerWithIdentifier:(NSString *)identifier { | |
@try { | |
return [self instantiateViewControllerWithIdentifier:identifier]; | |
} | |
@catch (NSException *exception) { |
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 UA_isIPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define UA_isIPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
#define UA_isRetinaDevice ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] >= 2) | |
#define UA_isMultiTaskingSupported ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] && [[UIDevice currentDevice] isMultitaskingSupported]) | |
#define UA_runOnMainThread if (![NSThread isMainThread]) { dispatch_sync(dispatch_get_main_queue(), ^{ [self performSelector:_cmd]; }); return; }; |
Starting from iOS 9, App Transport Security enforces to use secure HTTPS requests by default.
App Transport Security
App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you
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
self.startButton.rac_command = [RACCommand command]; | |
self.stopButton.rac_command = [RACCommand command]; | |
self.resetButton.rac_command = [RACCommand command]; | |
static const CGFloat interval = 0.01; | |
__unsafe_unretained id weakSelf = self; | |
// Signal id -> Signal Signal Number | |
// Map each click of the start button to a signal that fires at our interval | |
// and stops when the stop button's clicked. | |
id<RACSignal> start = [self.startButton.rac_command map:^(id _) { |
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
// meet Stringy - a simple string type with a fluent interface | |
struct Stringy { | |
let content: String | |
init(_ content: String) { | |
self.content = content | |
} | |
func append(appendage: Stringy) -> Stringy { |
OlderNewer