Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"String?' is not convertible to 'NSString'" (after Xcode 7 migration)

Tags:

ios

ios9

swift

Hello I'm developing project (finishing it in objective-c) but one class was writed in Swift. After migration to XCODE 7 for ios9 compiler back to me with Error: 'String?' is not convertible to 'NSString' for code:

if let view = self.emailTextField.rightView {
                    if (self.emailTextField.text as NSString).validateEmail() {
                        self.emailTextField.rightView?.alpha = 1
                    } else {
                        self.emailTextField.rightView?.alpha = 0
                    }
                }

Any advice from Swift2 Bosses :) ?

like image 702
Niedved Avatar asked Jan 07 '23 13:01

Niedved


1 Answers

Boss advice:

self.emailTextField.text as NSString becomes self.emailTextField.text! as NSString

:)

like image 193
Vatsal Manot Avatar answered Jan 19 '23 01:01

Vatsal Manot