Skip to content

Instantly share code, notes, and snippets.

View 0xlitf's full-sized avatar

0xCalcifer 0xlitf

  • 18:41 (UTC +08:00)
View GitHub Profile
@0xlitf
0xlitf / UIView+Extension.m
Last active December 3, 2015 08:59
Cocoa Touch
- (UIViewController *)viewController {
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
@0xlitf
0xlitf / code lines
Created December 3, 2015 08:56
Bash
find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" -or -name "*.rss" ")" -print | xargs wc -l
@0xlitf
0xlitf / PanGestureRecognizer
Last active December 5, 2015 04:21
panGesture
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];
[panGesture setMinimumNumberOfTouches:1];
[self.currentlistPageController.listPageView.planTableView addGestureRecognizer:panGesture];
- (void)panGestureHandler:(UIPanGestureRecognizer *)sender {
static double transitionOriginX;
@0xlitf
0xlitf / FMDB
Created December 4, 2015 08:52
//create
NSFileManager * fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:self.dbPath] == NO) {
// create it
FMDatabase * db = [FMDatabase databaseWithPath:self.dbPath];
if ([db open]) {
NSString * sql = @"CREATE TABLE 'User' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'name' VARCHAR(30), 'password' VARCHAR(30))";
BOOL res = [db executeUpdate:sql];
if (!res) {
debugLog(@"error when creating db table");
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeNavigationBarAlpha:) name:@"changeNavigationBarAlpha" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"changeNavigationBarAlpha" object:[NSString stringWithFormat:@"%f",a]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callBack1:) name:@"PosterOne" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callBack2:) name:@"PosterTwo" object:nil];
-(void)callBack1:(NSNotification*)notification{
@0xlitf
0xlitf / git命令速查
Last active December 5, 2015 04:21
git命令速查
http://www.git-tower.com/blog/content/posts/git-cheat-sheet-cn/git-cheat-sheet-large01-cn.png
@0xlitf
0xlitf / iOS jump URL
Created December 5, 2015 04:20
iOS跳到系统设置里的各种设置界面
NSURL *url = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
About — prefs:root=General&path=About
Accessibility — prefs:root=General&path=ACCESSIBILITY
Airplane Mode On — prefs:root=AIRPLANE_MODE
@0xlitf
0xlitf / iOS 事件处理机制与图像渲染过程
Created December 5, 2015 04:25
iOS 事件处理机制与图像渲染过程
iOS 事件处理机制与图像渲染过程
iOS RunLoop都干了什么
iOS 为什么必须在主线程中操作UI
事件响应
CALayer
CADisplayLink 和 NSTimer
iOS 渲染过程
渲染时机
CPU 和 GPU渲染
Core Animation
@0xlitf
0xlitf / singleton
Created December 5, 2015 10:48
#define singleton
#define instance_interface(className, instanceMothed) \
\
+(instancetype)instanceMothed;
//实现方法
#define instance_implementation(className, instanceMothed) \
\
static className *_instance;\
\