[swift] Closure with return value for A -> B sequentially

for setup Closure with return value for A -> B sequentially below

 

  func fetchPersonData(completion: (_ str: String) -> Void) {

    let str = "person"
    completion(str) //competition notification

  }

Run code

    fetchPersonData(){(str: String) in
      personLabel.text = str
    }

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です