Skip to content

Instantly share code, notes, and snippets.

View 0xlitf's full-sized avatar

0xlitf 0xlitf

  • 07:38 (UTC +08:00)
View GitHub Profile
//单例化一个类 instanceMothed:单例的方法名称
#define instance_interface(className, instanceMothed) \
\
+(instancetype)instanceMothed;
//实现方法
#define instance_implementation(className, instanceMothed) \
\
static className *_instance;\
\
@0xlitf
0xlitf / NSLog
Last active December 5, 2015 10:54
define NSLog
/**
* @brief 输出格式如下的打印信息:(类名:行数 打印的信息), 只有在DEBUG模式下输出,release模式不会输出(Build Settings 中 Preprocessor Macros 的 Debug 后边会有 DEBUG = 1 定义)
*/
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
//#define NSLog(FORMAT, ...) fprintf(stderr,"%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
@0xlitf
0xlitf / SQL.md
Last active December 5, 2015 16:25
SQL

##SQL DML 和 DDL

可以把 SQL 分为两个部分:数据操作语言 (DML) 和 数据定义语言 (DDL)

SQL (结构化查询语言)是用于执行查询的语法。但是 SQL 语言也包含用于更新、插入和删除记录的语法。 ####查询和更新指令构成了 SQL 的 DML 部分: SELECT - 从数据库表中获取数据 UPDATE - 更新数据库表中的数据 DELETE - 从数据库表中删除数据 INSERT INTO - 向数据库表中插入数据 ####SQL 的数据定义语言 (DDL) 部分使我们有能力创建或删除表格。我们也可以定义索引(键),规定表之间的链接,以及施加表间的约束。 ####SQL 中最重要的 DDL 语句:

@0xlitf
0xlitf / rules.md
Created December 5, 2015 17:25
编码规范
@0xlitf
0xlitf / .gitignore
Created December 5, 2015 18:03 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@0xlitf
0xlitf / .ignore
Created December 5, 2015 18:23
ignore
http://stackoverflow.com/questions/107701/how-can-i-remove-ds-store-files-from-a-git-repository
@0xlitf
0xlitf / fmdb.demo
Created December 6, 2015 04:54
fmdb.demo
// ViewController.m
// JRFMDB
//
// Created by jerehedu on 15/6/18.
// Copyright (c) 2015年 jerehedu. All rights reserved.
//
#import "ViewController.h"
#import "FMDatabase.h"
@0xlitf
0xlitf / fmdb.md
Created December 6, 2015 10:13
fmdb
遍历一下ID和city

NSString *databasePath = [[NSBundle mainBundle] pathForResource:@"weathercity" ofType:@"sqlite"];

FMDatabase *db = [FMDatabase databaseWithPath:databasePath];

if (![db open]) {

NSLog(@"open fail");

@0xlitf
0xlitf / assert test.md
Created December 7, 2015 08:40
assert test

XCTFail(format…) 生成一个失败的测试;

XCTAssertNil(a1, format...)为空判断,a1为空时通过,反之不通过;

XCTAssertNotNil(a1, format…)不为空判断,a1不为空时通过,反之不通过;

XCTAssert(expression, format...)当expression求值为TRUE时通过;

XCTAssertTrue(expression, format...)当expression求值为TRUE时通过;

@0xlitf
0xlitf / 初始化抛异常
Created December 10, 2015 11:33
初始化抛异常
- (id)init
{
@throw [NSException exceptionWithName:NSGenericException reason:@"init not supported, use initWithTableView: instead." userInfo:nil];
return nil;
}