A simple idea using the trick of keypath(...)
derived from libextobjc and ReactiveCocoa and null-object pattern.
Create a category method in NSObject and define a macro PropertyNameForClass()
.
NSObject+PropertyName.h:
#import
platform :ios, '7.0' | |
# Core Data | |
pod 'SSDataKit', :git => 'https://github.com/soffes/SSDataKit', :commit => '60d432e734ae11e8cfedac8ac5f68c0ce8a1b9ba' | |
# On-disk & in-memory caching | |
pod 'SAMCache' | |
# Fast image view for Core Image | |
pod 'SAMCoreImageView', '0.1.3' |
extension Int { | |
func times(task:() -> ()) { | |
for i in 0..self { | |
task() | |
} | |
} | |
} | |
5.times { | |
println("Hey! You look really like Ruby") |
changeAlert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert]; | |
UIAlertController* __weak weakAlert = changeAlert; | |
UIAlertAction *alertActionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { | |
UITextField *t = [[weakAlert textFields] firstObject]; | |
DLog(@"%@",t.text); | |
[weakAlert dismissViewControllerAnimated:YES completion:nil]; | |
}]; | |
UIAlertAction *alertActionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { | |
DLog(@"%@",action); |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
@import Foundation; | |
@interface KKWatchAppNotificationCenter : NSObject | |
+ (instancetype)sharedCenter; | |
- (void)postNotification:(NSString *)key; | |
- (void)addTarget:(id)target selector:(SEL)selector name:(NSString *)notification; | |
- (void)removeObserver:(NSObject *)observer; | |
@end |
A simple idea using the trick of keypath(...)
derived from libextobjc and ReactiveCocoa and null-object pattern.
Create a category method in NSObject and define a macro PropertyNameForClass()
.
NSObject+PropertyName.h:
#import
extension WKInterfaceController { | |
func animateWithDuration(duration: NSTimeInterval, animations: () -> Void, completion: (() -> Void)?) { | |
animateWithDuration(duration, animations: animations) | |
let delay = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Double(NSEC_PER_SEC))) | |
dispatch_after(delay, dispatch_get_main_queue()) { | |
completion?() | |
} | |
} | |
PS: If you liked this talk or like this concept, let's chat about iOS development at Stitch Fix! #shamelessplug
Speaker: David Abrahams. (Tech lead for Swift standard library)
"Crusty" is an old-school programmer who doesn't trust IDE's, debuggers, programming fads. He's cynical, grumpy.
OOP has been around since the 1970's. It's not actually new.
Classes are Awesome
var fetchedResultsProcessingOperations: [NSBlockOperation] = [] | |
private func addFetchedResultsProcessingBlock(processingBlock:(Void)->Void) { | |
fetchedResultsProcessingOperations.append(NSBlockOperation(block: processingBlock)) | |
} | |
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) { | |
switch type { | |
case .Insert: |