Skip to content

Instantly share code, notes, and snippets.

@noa4021J
Created June 9, 2019 02:23
Show Gist options
  • Save noa4021J/6bb2c76ca7485d7ac14df1711e9192b1 to your computer and use it in GitHub Desktop.
Save noa4021J/6bb2c76ca7485d7ac14df1711e9192b1 to your computer and use it in GitHub Desktop.
private lazy var onlyOnceRun: (()->Void)? = {
//ViewDidLayoutSubviewsの中で1度だけ実行されるコード
print("2回目以降は出力されないよ")
//1度実行された直後にnilを返すため2回目以降は実行されない
return nil
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment