Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
@jeksys
jeksys / gist:1423460
Created December 2, 2011 14:41
jumping to background
dispatch_queue_t callerQueue = dispatch_get_current_queue();
dispatch_retain(callerQueue);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work in the other thread...
// Example: NSArray* items = parseJSON(data);
dispatch_async(callerQueue, ^{
@jeksys
jeksys / gist:1507490
Created December 21, 2011 20:07
Custom modal UIViewController transitions
Just a snippet.
Note: Don’t push or remove view controllers with non-opaque views. The underlying view of the parent view controller is removed.
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
transition.duration = animated ? 0.5f : 0.0f;
transition.fillMode = kCAFillModeForwards;
@jeksys
jeksys / gist:1797397
Created February 11, 2012 07:04
KeyboardHide show
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShown:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];}
@jeksys
jeksys / UIColor+myColors.m
Created February 18, 2012 23:17
myColors
@interface UIColor (myColors)
+ (UIColor *)questListTableViewColor;
+ (UIColor *)defaultBackground;
+ (UIColor *)defaultBackgroundColor;
@end
@implementation UIColor (myColors)
+ (UIColor *)questListTableViewColor
{
#import <UIKit/UIKit.h>
@interface UITableViewCellEnterText : UITableViewCell<UITextFieldDelegate>{
UITextField *textField;
}
@property (nonatomic, retain) NSMutableDictionary *Value;
@property (nonatomic, readonly) NSString *StringValue;
@property (nonatomic, retain) UITextField *textField;
@jeksys
jeksys / gist:1961023
Created March 2, 2012 20:21
Key Frame Animation
-(IBAction)buttonPress:(id)sender
{
NSString *keyPath = @"anchorPoint.x";
CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:keyPath];
[kfa setValues:[NSArray arrayWithObjects:
[NSNumber numberWithFloat:-.05],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.1],
[NSNumber numberWithFloat:.1],
[NSNumber numberWithFloat:-.05],
@jeksys
jeksys / gist:2065535
Created March 17, 2012 21:40
NSNumber.Currency
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
@jeksys
jeksys / gist:2065546
Created March 17, 2012 21:41
NSDate.localDate
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
@jeksys
jeksys / gist:2394945
Created April 15, 2012 21:41
timer debug macros
OTHER_CFLAGS = -DDEBUG=1
#define MARK CMLog(@"%s", __PRETTY_FUNCTION__);
#define CMLog(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
CMLog(@"My iPhone is an %@, v %@", [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion]);
#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
#if DEBUG==1