Skip to content

Instantly share code, notes, and snippets.

@minsOne
minsOne / gist:2a8dadb1ebc49050ab18
Created June 17, 2014 06:21
UIButton 클릭시 커졌다 작아지는 애니메이션 효과
UIButton *button = (UIButton *)sender;
button.transform = CGAffineTransformMakeScale(1.2, 1.2);
[UIView animateWithDuration:0.2 animations:^{
button.transform = CGAffineTransformMakeScale(1.0, 1.0);
} completion:^(BOOL finished) {
}];
UIViewController *mainViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
while (mainViewController.presentedViewController != nil) {
mainViewController = mainViewController.presentedViewController;
}
[mainViewController presentViewController:kidsLockViewController animated:YES completion:nil];
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.contentView.backgroundColor = [UIColor clearColor];
UIView *whiteRoundedCornerView = [[UIView alloc] initWithFrame:CGRectMake(10,10,300,70)];
whiteRoundedCornerView.backgroundColor = [UIColor whiteColor];
whiteRoundedCornerView.layer.masksToBounds = NO;
whiteRoundedCornerView.layer.cornerRadius = 3.0;
whiteRoundedCornerView.layer.shadowOffset = CGSizeMake(-1, 1);
whiteRoundedCornerView.layer.shadowOpacity = 0.5;
[cell.contentView addSubview:whiteRoundedCornerView];
- (NSString *)encodeURL:(NSString *)url {
NSString * encoded = (__bridge NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef)url,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
return encoded;
}
UIViewController willRotateToInterfaceOrientation:duration:]
[UIViewController viewWillLayoutSubviews]
[UIView layoutSubviews]
[UIViewController viewDidLayoutSubviews]
[UIViewController willAnimateRotationToInterfaceOrientation:duration:]
[UIViewController shouldAutorotateToInterfaceOrientation:]
[UIViewController didRotateFromInterfaceOrientation:]
And when presenting a view controller we get the following:
[UIViewController loadView]
NSLog(@"%@", [UIPasteboard generalPasteboard].string);
[[UIPasteboard generalPasteboard] setString:@"google.com"];
NSLog(@"%@", [UIPasteboard generalPasteboard].string);
[UIPasteboard generalPasteboard];
@minsOne
minsOne / Bubble Sort in Objective C
Created August 12, 2014 14:59
Bubble Sort in Objective-C
- (NSArray *)bubbleSort:(NSMutableArray *)unsorted comparator:(NSComparator)comparator
{
BOOL done = false;
while (!done) {
done = true;
for (int i = 1; i < unsorted.count; i++) {
if (comparator( [unsorted objectAtIndex:i-1], [unsorted objectAtIndex:i] ) == NSOrderedDescending ) {
[unsorted exchangeObjectAtIndex:i withObjectAtIndex:i-1];
done = false;
@minsOne
minsOne / RaceCondition in Coding Test
Last active August 29, 2015 14:05
RaceCondition using GCD in Objective-C
/*
RaceCondition using GCD in Objective-C
localCountLabel and globalCountLabel increment 1, 5 through each Thread
*/
__block NSUInteger localCount1, localCount2, localCount3, globalCount;
UILabel *localCountLabel1, *localCountLabel2, *localCountLabel3, *globalCountLabel;
localCountLabel1 = [[UILabel alloc]init];
localCountLabel2 = [[UILabel alloc]init];
@minsOne
minsOne / Reverse String in Objc
Created August 24, 2014 09:35
Reverse String in Objc
NSString *str = @"Hello,World";
NSString *fowardStr = @"";
NSString *behindStr = @"";
for (NSInteger i = str.length/2-1; i >= 0; i--) {
NSLog(@"Foward : %c", [str characterAtIndex:i]);
fowardStr = [fowardStr stringByAppendingString:[NSString stringWithFormat:@"%c", [str characterAtIndex:i]]];
}
@minsOne
minsOne / Decorator_Pattern.swift
Created September 23, 2014 12:24
Decorator Pattern in Swift
protocol Coffee {
func getCost() -> Double
func getIngredients() -> String
}
class SimpleCoffee: Coffee {
func getCost() -> Double {
return 1.0
}
func getIngredients() -> String {