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); |
| // app delegate | |
| #import <FBTweak.h> | |
| #import <FBTweakShakeWindow.h> | |
| #import <FBTweakInline.h> | |
| #import <FBTweakViewController.h> | |
| #ifdef DEBUG | |
| BOOL static const IS_DEBUG = YES; | |
| #else | |
| BOOL static const IS_DEBUG = NO; |
| import Foundation | |
| extension Int { | |
| var days:Int { | |
| return 60*60*24*self | |
| } | |
| var ago:NSDate { | |
| return NSDate().dateByAddingTimeInterval(-Double(self)) | |
| } | |
| } |
| // define Swift postfix function like Linux Shell background operator | |
| operator postfix & {} | |
| @postfix func & (backgroundClosure: () -> ()) { | |
| dispatch_async(_queue) { | |
| backgroundClosure() | |
| } | |
| } | |
| // testing log function | |
| func log(message: String) |
| // 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 |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| //Add some method process in global queue - normal for data processing | |
| dispatch_async(dispatch_get_main_queue(), ^(){ | |
| //Add method, task you want perform on mainQueue | |
| //Control UIView, IBOutlet all here | |
| }); |
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