I am trying to compare two strings and then " do something". The first string is a string that is captured in UITextView using the following code:
**********************************
func updateIncomingData ()
{
NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "Notify"), object: nil , queue: nil)
{
notification in
let appendString = "\n"
let myFont = UIFont(name: "Helvetica Neue", size: 30.0)
let myAttributes2 = [NSFontAttributeName: myFont!, NSForegroundColorAttributeName: UIColor.red]
let attribString = NSAttributedString(string: "" + (characteristicASCIIValue as String) + appendString, attributes: myAttributes2)
let newAsciiText = NSMutableAttributedString(attributedString: self.consoleAsciiText!)
self.password_P_F.attributedText = NSAttributedString(string: characteristicASCIIValue as String , attributes: myAttributes2)
newAsciiText.append(attribString)
self.consoleAsciiText = newAsciiText
self.password_P_F.attributedText = self.consoleAsciiText
let pwmatch:String = "The passwords match"
let pwin:String = self.password_P_F.text
/
print("INPUT PASSWORD" + pwin)
print("COMPARE TO" + pwmatch)
if(pwin == "The passwords match" )
{
print("NOW HERE IT IS")
}
if (pwin == pwmatch)
{
print("at the passwords match")
/
}
}
********************************************************
The debugger shows the incoming string as "Value Received: The passwords match". The following is the debugger window.
****************************
Value Recieved: The passwords match
INPUT PASSWORDThe passwords match
The passwords match
COMPARE TOThe passwords match
*************************
The compare statement "if(pwin == "The passwords match" )" does not return a true but if I type in "The passwords match" instead of using "self.password_P_F.text", the compare statement returns TRUE.
There must be something in the string "self.password_P_F.text" that is different but I cannot figure out what it is.
Any help appreciated.
Thanks
Bill