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
import UIKit | |
protocol UIViewControllerProtocol { | |
// hogehoge... | |
} | |
extension UIViewController: UIViewControllerProtocol { | |
} | |
var viewController: protocol<UIViewControllerProtocol, UITableViewDelegate>! = nil |
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
extension Dictionary { | |
func map<K, V>(f: (Key, Value) -> (K, V)) -> [K: V] { | |
var r = Dictionary<K, V>(minimumCapacity: self.count) | |
for key in self.keys { | |
let (k, d) = f(key, self[key]!) | |
r[k] = d | |
} | |
return r | |
} | |
} |
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
// 鳥とバランス棒のシノニムを定義 | |
typealias Birds = Int | |
typealias Pole = (left: Birds, right: Birds) | |
// 左右に鳥が飛んできたことを表現 | |
func landLeft(n: Birds) -> Pole -> Pole { | |
return {p in (p.left + n, p.right)}; | |
} | |
func landRight(n: Birds) -> Pole -> Pole { |
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
#import "NSObject+performSelector.h" | |
@implementation NSObject (performSelector) | |
- (void)call:(NSString *)sel { | |
[self performSelector:@selector(sel)]; | |
} | |
- (id)get:(NSString *)sel { | |
return [self performSelector:@selector(sel)]; |
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
@implementation HideTabBar | |
+ (void)tabBarHidden:(BOOL)hide tabBar:(UITabBarController *)tabBarController { | |
CGFloat viewHeight = [self viewHeight:hide]; | |
for (UIView *view in tabBarController.view.subviews) { | |
CGRect _rect = view.frame; | |
if ([view isKindOfClass:[UITabBar class]]) { | |
_rect.origin.y = viewHeight; | |
} else { |
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
require 'set' | |
class Bunch | |
def initialize(bunch1, bunch2 = nil) | |
(bunch2 != nil) ? mergeBunch(bunch1, bunch2) : initValue(bunch1) | |
end | |
def initValue(value) | |
@bunch1 = nil | |
@bunch2 = nil | |
@value = value |
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
+ (instancetype)sharedManager { | |
static id manager_ = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
manager_ = [[self alloc] init]; | |
}); | |
return manager_; | |
} |
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
// pod 'NSDate-Escort' | |
// pod 'AZDateBuilder' | |
#import "NSDate+Escort.h" | |
#import "NSDate+AZDateBuilder.h" | |
NSDate *date = [[[NSDate date] dateByAddingDays:1] AZ_dateByUnit: @{ | |
AZ_DateUnit.hour : @9, | |
AZ_DateUnit.minute : @0, | |
AZ_DateUnit.second : @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
@implementation HogeViewController { | |
__weak IBOutlet UIView *piyo; | |
} | |
@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
- (IBAction)touchMove:(id)sender { | |
__weak typeof (self) this = self; | |
[self performSegueWithIdentifier:kSeguePicture sender:^(id controller) { | |
[controller setViewObject:this.viewObject]; | |
}]; | |
} | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(void (^)(id))sender { | |
if (sender) { |