原文链接:https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9f782
作者: Chris Lattner
Author: Chris Lattner
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
/** | |
* Width of hairline (1px on real device screen) | |
* The dppx of screens can be found here http://dpi.lv/ | |
* | |
* @return CGFloat number to be set for "1px" | |
*/ | |
+ (CGFloat)hairLineWidth { | |
if ([UIScreen mainScreen].bounds.size.width == 414.f) { // Plus | |
return 1.f / 2.46f; // 2.46 is the dppx of plus screens | |
} else { |
#-*-coding:utf-8-*- | |
import hashlib | |
import hmac | |
import time | |
import requests | |
HMAC_KEY = '5tT!TQkf5fYbabw5?KL2659XgL^JgxWw8r9Y+bAvGwP-QfteQL' | |
class TanTan(object): |