Skip to content

Instantly share code, notes, and snippets.

@yutailang0119
Created July 1, 2016 07:06
Show Gist options
  • Save yutailang0119/9143bb094e576e1e8abc274938914052 to your computer and use it in GitHub Desktop.
Save yutailang0119/9143bb094e576e1e8abc274938914052 to your computer and use it in GitHub Desktop.
//例えばUITableViewの更新
@IBOutlet weak var tableView: UITableView!
let str = "hoge"
// 1
let complete1 = { [weak self]() in
if let weakSelf = self {
print(weakSelf.str) // プロパティにアクセスする => str
weakSelf.tableView.reloadData() // メソッドを使う
}
}
// 2
let complete2 = { [weak self]() in
print(self?.str) // プロパティにアクセスする => Optional("hoge")
self?.tableView.reloadData() // メソッドを使う
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment