import UIKit
class NSLocalImageURLProtocol: URLProtocol {
static let schemaName = "myapp"
override class func canInit(with request: URLRequest) -> Bool {
if let schema = request.url?.scheme?.lowercased(),
sch[......]
import UIKit
class NSLocalImageURLProtocol: URLProtocol {
static let schemaName = "myapp"
override class func canInit(with request: URLRequest) -> Bool {
if let schema = request.url?.scheme?.lowercased(),
sch[......]
var myGroup = DispatchGroup()
override func viewDidLoad() {
super.viewDidLoad()
for i in 0 ..< 5 {
myGroup.enter()
Alamofire.request("https://httpbin.org/get", parameters: ["foo": "bar"]).responseJSON { response[......]
As of Swift 2.0, you don't need to write your own extension to filter nil values from an Array, you can use flatMap, which flattens the Array and filters nils:
let optionals : [String?] = ["a", "b", nil, "d"]
let nonOptionals = optionals.flatMap{$0[......]
import UIKit
import YYText
import SnapKit
class YYCell: UITableViewCell {
fileprivate static let fontSize: CGFloat = 24
fileprivate static let font = UIFont.systemFont(ofSize: YYCell.fontSize)
fileprivate lazy var wrapView: UI[......]
代码如下:
注意priority high是关键
class YYCell: UITableViewCell {
fileprivate var tvHeightConstraint: Constraint? = nil
....
fileprivate func setupUI() {
textView.snp.makeConstraints { (make) in
make.top.equalToSupervi[......]