swift2.1

Checking if text fields are empty cause error in Swift 2

南笙酒味 提交于 2019-12-02 15:54:08
问题 I am trying to check if a textbox has no value. When I do this: if(userEmail?.isEmpty || userPassword?.isEmpty || userPasswordRepeat?.isEmpty) I get the following error I tried adding "?" before the ".isEmpty" but the error won't go away Any ideas? 回答1: Try this.... if txtEmail.text?.isEmpty == true || txtPassword.text?.isEmpty == true || txtRePassword.text?.isEmpty == true{ print("true") } 回答2: If interested also in positive case, the following is an alternative solution for Swift 2 : let

Swift 2.1 [UInt8] --utf8--> String?

旧巷老猫 提交于 2019-11-27 16:20:12
I know questions like this exist on both Stack Overflow and elsewhere. But it seems to have evolved a lot as well. Given a list of UInt8 (a swift byte array basically), what is the easiest/idiomatic way to covert it to a swift String ? I'm particularly interested in the method that doesn't use NSData/NSString, since if Santa brings Swift to the world of Linux, it will undoubtedly be without the NS libraries, and I'd like to know how to do it in just Swift. let buffUInt8: Array<UInt8> = [97, 98, 115, 100, 114, 102, 103, 104, 0] // you need Int8 array let buffInt8 = buffUInt8.map{ Int8

Swift Modal View Controller with transparent background [duplicate]

橙三吉。 提交于 2019-11-27 10:22:06
This question already has an answer here: Transparent background for modally presented viewcontroller 4 answers I know this topic is quite popular, but I'm a little iniciate problem in a programming language, the fact is that I still do not understand where I put the code. Well, I'll tell the whole case: I'm trying to make a modal Swift in a little different from normal: By clicking on a button, the ViewController is displayed (following modal type) on the screen, but with transparent background. Only the blue View with label will be displayed. When this ViewController is presented, it is with

Swift Modal View Controller with transparent background [duplicate]

你离开我真会死。 提交于 2019-11-26 11:52:16
问题 This question already has answers here : Transparent background for modally presented viewcontroller (4 answers) Closed 4 years ago . I know this topic is quite popular, but I\'m a little iniciate problem in a programming language, the fact is that I still do not understand where I put the code. Well, I\'ll tell the whole case: I\'m trying to make a modal Swift in a little different from normal: By clicking on a button, the ViewController is displayed (following modal type) on the screen, but