public void Delete() { using (var s = new NSMutableString(0)) { s.SetString((NSString)"Hello World"); s.DeleteCharacters(new NSRange(5, 6)); Assert.That(s.ToString(), Is.EqualTo("Hello"), "deleetd"); Assert.Throws <ArgumentOutOfRangeException> (delegate { s.DeleteCharacters(new NSRange(0, s.Length + 1)); }, "bad 1"); Assert.Throws <ArgumentOutOfRangeException> (delegate { s.DeleteCharacters(new NSRange(1, s.Length)); }, "bad 2"); } }
public override void Changed(UITextView textView) { Console.WriteLine("-----" + secureText); if (secureTextViewEntry) { string text = textView.Text; if (text.Length > 0) { if ("" == lastText) { secureText.DeleteCharacters(new NSRange(secureText.Length - 1, 1)); onlyPassword(); timer.Invalidate(); //base.Changed(textView); return; } else { NSString one = new NSString(text.Substring(text.Length - 1)); secureText.Append(one); NSMutableString temp = new NSMutableString(); for (int i = 0; i < secureText.Length - 1; i++) { temp.Append(new NSString("•")); } temp.Append(new NSString(secureText.ToString().Substring(secureText.ToString().Length - 1))); myTextView.Text = temp; //timer.Invalidate(); timer = NSTimer.CreateScheduledTimer(2, onlyPassword); } } else { secureText = new NSMutableString(); } //base.Changed(textView); } else { if (textView.Text.Length == 0) { secureText = new NSMutableString(); } else { secureText = new NSMutableString(); secureText.SetString(new NSString(textView.Text)); } timer.Invalidate(); //base.Changed(textView); } }