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
infix operator --> { associativity left precedence 160 } | |
/// True if and only if lhs implies rhs. | |
/// False if lhs is true and rhs false, true otherwise. | |
func -->(lhs: Bool, rhs: Bool) -> Bool { | |
return !lhs || rhs | |
} |
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
class Cell: UITableViewCell { | |
func hello() -> String { | |
return "hello" | |
} | |
} | |
var payload = [Int: AnyObject]() | |
payload[1] = Cell() |
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 UIColor { | |
convenience init(_ hexValue: Int) { | |
let r = (hexValue & 0xFF0000) >> 16 | |
let g = (hexValue & 0x00FF00) >> 8 | |
let b = hexValue & 0x0000FF | |
self.init(red: CGFloat(r)/255, green: CGFloat(g)/255, blue: CGFloat(b)/255, alpha: 1) | |
} | |
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
func functionWithClosure(closure: () -> ()) { | |
closure() | |
} | |
func topFunction() { | |
let button = UIButton() | |
let image = UIImage() | |
func nestedFunction() { | |
button.setImage(image, forState: .Normal) |
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
var dictionary = ["yolo": 9] | |
func objectForKey<T>(key: String) -> T? { | |
let obj = dictionary[key] | |
if let obj = obj as? T { | |
return obj | |
} | |
return 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
-(void)reloadData { | |
BOOL canAnimate = !self.visibleCells.count; | |
[self reloadData]; | |
if (canAnimate) { | |
CABasicAnimation* revealAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"]; | |
revealAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
revealAnimation.duration = 0.3f; | |
[revealAnimation setToValue:[NSNumber numberWithFloat:0.0f]]; |
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
-(BOOL)performSelectorIfResponding:(SEL)selector withObjects:(id)firstParameter, ... { | |
if (![self respondsToSelector:selector]) { | |
return NO; | |
} | |
NSMethodSignature* signature = [self.class instanceMethodSignatureForSelector:selector]; | |
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature]; | |
invocation.target = self; | |
invocation.selector = 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
OARequestParameter* likesParameter = [OARequestParameter requestParameter:@"likes" value:@"1"]; | |
NSURL* URL = [NSURL URLWithString:dashboardURL]; | |
__block void (^successBlock)(AFHTTPRequestOperation *operation, id JSON); | |
__block void (^alternateSuccessBlock)(AFHTTPRequestOperation *operation, id JSON); | |
if (ID && block) { | |
__block int offset = 0; | |
__block NSMutableArray* allPosts = [NSMutableArray array]; | |
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
-(BOOL)containsSubstring:(NSString *)substring { | |
return ([self rangeOfString:substring].location != NSNotFound); | |
} |
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
-(void)didReceiveMemoryWarning { | |
[super didReceiveMemoryWarning]; | |
NSMutableDictionary* cells = [self.tableView valueForKey:@"_reusableTableCells"]; | |
for (UITableViewCell* cell in self.tableView.visibleCells) { | |
if ([cell.reuseIdentifier isEqualToString:@"Text"]) { | |
return; | |
} | |
} | |
[cells removeObjectForKey:@"Text"]; |
NewerOlder