ios - How to use .isempty in OS X swift -
i new swift, , i'm trying make login program mac os x. know swift programming on ios, don't know os x swift. wrote program os x. finished it, need know how check whether text fields empty or not. in ios, can using .isempty property. doesn’t work on os x though. how can this?
class insideviewcontroller: nsviewcontroller { @iboutlet var usernametext: nstextfield! @iboutlet var passwordtext: nssecuretextfield! @iboutlet var conformpasswordtext: nssecuretextfield! override func viewdidload() { super.viewdidload() // additional setup after loading view. } override var representedobject: anyobject? { didset { // update view, if loaded. } } @ibaction func signupbutton(sender: nsbutton) { let username = usernametext.stringvalue let userpassword = passwordtext.stringvalue let userpasswordcon = conformpasswordtext.stringvalue nsuserdefaults.standarduserdefaults().setobject(username, forkey: "username") nsuserdefaults.standarduserdefaults().setobject(userpassword, forkey: "userpassword") nsuserdefaults.standarduserdefaults().synchronize() if (usernametext.isempty) } }
if usernametext.stringvalue == "" { //action }
as seen here can access text of nstextfield using stringvalue
property, can used modify text.