Skip to content

Instantly share code, notes, and snippets.

View Appletone's full-sized avatar
💻
Coding

Lin Chia Hua Appletone

💻
Coding
  • Taipei, Taiwan
View GitHub Profile
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);
@Appletone
Appletone / FBTweak
Last active August 29, 2015 14:03
How to use Facebook Tweaks (FBTweak)
// 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))
}
}
@Appletone
Appletone / gist:d8d2cbd91c5dbe05861c
Last active August 29, 2015 14:04
Swift postfix function like Linux Shell background operator
// 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)
@Appletone
Appletone / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// 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
});
@Appletone
Appletone / Objective-C the get property name string for a class and check it at compile-time.md
Last active August 29, 2016 12:02 — forked from xareelee/NSObject+PropertyName.h
Objective-C the get property name string for a class and check it at compile-time

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