This file contains 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
UISearchBar *searchBar = [[[UISearchBar alloc] initWithFrame:CGRectZero] autorelease]; | |
[searchBar sizeToFit]; | |
self.tableView.tableHeaderView = searchBar; | |
[[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self] autorelease]; | |
self.searchDisplayController.delegate = self; | |
self.searchDisplayController.searchResultsDataSource = self; | |
self.searchDisplayController.searchResultsDelegate = self; |
This file contains 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
#if NS_BLOCKS_AVAILABLE | |
- (void)showWhileExecutingBlock:(void (^)())block animated:(BOOL)animated { | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { | |
block(); | |
dispatch_async(dispatch_get_main_queue(), ^(void) { | |
[self cleanUp]; | |
}); | |
}); | |
This file contains 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
@interface NSString (Times) | |
- (void)times:(void (^)(void))block; | |
@end | |
@implementation NSString (Times) | |
- (void)times:(void (^)(void))block { | |
for (NSUInteger index = 0; index < [self longLongValue]; index++) { | |
block(); | |
} | |
} |
This file contains 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
@interface NSObject (Curry) | |
- (id)curry:(SEL)selector; | |
@end | |
@implementation NSObject (Curry) | |
- (id)curry:(SEL)selector { | |
NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:selector]; | |
if (signature) { | |
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; | |
invocation.selector = selector; |
This file contains 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)perform { | |
UIViewController *sourceViewController = (UIViewController *)self.sourceViewController; | |
UIViewController *destinationViewController = (UIViewController *)self.destinationViewController; | |
[UIView transitionWithView:sourceViewController.navigationController.view | |
duration:0.2 | |
options:UIViewAnimationOptionTransitionFlipFromLeft | |
animations:^{ | |
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO]; | |
} | |
completion:nil]; |
This file contains 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
tell application "Mail" | |
set selectedMails to the selection | |
using terms from application "MailTagsHelper" | |
set keyword to keywords of item 1 of selectedMails | |
set myproject to project of item 1 of selectedMails | |
end using terms from | |
display dialog keyword | |
display dialog myproject | |
end tell |
This file contains 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
println(args(0).toList.reverse.zipWithIndex.map{case(x,i)=>val k=" 十百千"(i) | |
val n=" 一二三四五六七八九"(x.toString.toInt) | |
n match{case' '=>""case'一'if k!=' '=>k | |
case _=>n+k.toString}}.reverse.mkString.trim) |
This file contains 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
NSButton *button = [[NSButton alloc] init]; | |
[button setImage:[NSImage imageNamed:@"Foo"]]; | |
button.imagePosition = NSImageLeft; | |
button.title = @"text" | |
[button setBordered:NO]; |
This file contains 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
[[[[NSNotificationCenter defaultCenter] rac_addObserverForName:notification object:nil] takeUntil:[self rac_willDeallocSignal]] subscribeNext:^(NSNotification *notification) { | |
NSLog(@"%@", notification); | |
}]; |
This file contains 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
[[object rac_valuesAndChangesForKeyPath:@keypath(object, keypath) options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld observer:nil] subscribeNext:^(RACTuple *tuple) { | |
NSDictionary *changeDictionary = tuple.second; | |
if (![changeDictionary[@"new"] isEqualToNumber:changeDictionary[@"old"]]) { | |
} | |
}]; |
OlderNewer