This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Soroush Khanlou ,URL: [Decoding JSON in Swift](http://khanlou.com/2016/04/decoding-json/) | |
import Foundation | |
struct ParserError:Error{ | |
let message:String | |
} | |
struct Parser { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
class Pokemon :CustomStringConvertible{ | |
let name: String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
引自 Pointers on C 一书 | |
1. 在调用宏时,首先对参数进行检查,查看是否包含任何由 `#define` 定义的符号,如果是,这些符号首先被替换掉 | |
2. 替换文本随后被插入到程序中原来文本的位置,对于宏,参数名被它们的值所替换。 | |
3. 最后,再次对结果文本进行扫描,看看它是否包含了任何由#define 定义的符号,如果是,就重复上述处理步骤。 | |
宏参数和#define 定义可以包含其他#define 定义的符号,但是,宏不可以出现递归! | |
当预处理器搜索#define定义的符号时,字符串常量的内容不被检查,如果想把宏参数插入到字符串常量中,有以下几种方式: | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 面向协议的日志输出 | |
enum LogLevel: Int { | |
case verbose = 1 | |
case debug = 2 | |
case info = 3 | |
case warning = 4 | |
case error = 5 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let url = URL(string:"http://localhost/test1.json")! | |
typealias JSONDictionary = [String:AnyObject] | |
// 资源的链接 & 解析闭包 | |
struct Resource<A>{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct student{ | |
const char *name; | |
int age; | |
char tag; | |
}; | |
int main(int argc, const char * argv[]) { | |
// 方式一 | |
struct student st_student1 = {"Alan",10,'1'}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stat -f "Access (atime): %Sa%nModify (mtime): %Sm%nChange (ctime): %Sc%nBirth (Btime): %SB" Screenshot_FFFDA56C-3018-4EA8-8A8B-2589E9C47865.jpg | |
date -r Screenshot_FFFDA56C-3018-4EA8-8A8B-2589E9C47865.jpg +%Y-%m-%d-%H:%M:%S |