Skip to content

Instantly share code, notes, and snippets.

@Zhukn1
Zhukn1 / Delay func
Created June 28, 2015 16:36
A handy and elegant implementation of the GCD's dispatch_after method.
func delay(delay:Double, closure:()->()) {
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
Int64(delay * Double(NSEC_PER_SEC))
),
dispatch_get_main_queue(), closure)
}
@Zhukn1
Zhukn1 / gist:75064415269a784571d3
Created January 26, 2015 05:26
Last completion block not called.
- (void)perform {
UIViewController *sourceController = self.sourceViewController;
UIViewController *destinationController = self.destinationViewController;
UIView *destView = destinationController.view;
destView.alpha = 0;
[sourceController.view addSubview:destView];
destView.frame = CGRectMake(0, 0,
CGRectGetWidth(sourceController.view.bounds),
@Zhukn1
Zhukn1 / gist:a4b11ec90dcf13c3124c
Last active August 29, 2015 14:12
Count the number of letter occurrences in a given string.
//initial string
NSString *str = @"the quick brown fox jumped over the fence";
//convert string to array of characters
NSMutableArray *stringArray = [NSMutableArray array];
[str enumerateSubstringsInRange:NSMakeRange(0, str.length)
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[stringArray addObject:[substring lowercaseString]];
}];
@Zhukn1
Zhukn1 / abc.txt
Last active November 26, 2022 07:26
Recursive Ailrine Logo downloading from web
AA,
AB,
AC,
AD,
AE,
AF,
AG,
AH,
AI,
AJ,