首先,找到的是以下這篇 StackOverflow https://stackoverflow.com/questions/28394933/how-do-i-check-when-a-uitextfield-changes 才發現 Swift 版本不同,用法也不同,怪怪。 目前 Swift 的版本為 4.2,所以就參考 Swift 4 的部份吧。 但剛透過以下連結,查了公司 Mac 中的 Swift 版本,已經到 5.0 了。 https://stackoverflow.com/questions/31247229/which-version-of-swift-compiler-is-the-default-xcode-6-4 xcrun swift --version ————————————————————————————————— 在撰寫 addTarget 時,遇上了以下的問題 Argument of '#selector' refers to instance method 'xxx' that is not exposed to Objective-C Add '@objc' to expose this instance method to Objective-C 網路上查到以下這篇,當中有原文說明。 https://blog.csdn.net/KevinQueen/article/details/78286189 有兩種處理方式,一是在 func 前加上 @objc,另一個是在 class 上方加上 @objcMembers。