Skip to content

Instantly share code, notes, and snippets.

@susieyy
Created January 14, 2017 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susieyy/d316547800b35d8380a2875b573619a6 to your computer and use it in GitHub Desktop.
Save susieyy/d316547800b35d8380a2875b573619a6 to your computer and use it in GitHub Desktop.
#swtws
final class HogeViewController: UIViewContoller {
private lazy var emptyView: UIView = {
let view = UIView()
self.view.addSubview(view)
view.snp_makeConstraints { $0.edges.equalToSuperview() }
let label = UILabel()
label.textAlignment = .center
label.text = "No data"
view.addSubview(label)
label.snp_makeConstraints { $0.center.width.equalToSuperview() }
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
// リクエスト部分は擬似コードです
Session.shard.request() { [weak self] response in
// 以下の最初の参照時に初めてemptyViewが初期化される
emptyView.hidden = (response.count > 0)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment