How do you automatically update a string variable when a user types in a UITextView?
I have a string variable and UITextView, when a user type something in the UITextView, the string must be updated automatically, so that it's 开发者_StackOverflow社区value changes as UITextView's does. What I mean is this code should automatically change the string.
myString.String = textView.text;
Thank you.
Assign a delegate
to your UITextView
and implement the textViewDidChange:
method:
- (void)textViewDidChange:(UITextView *)textView {
self.myString = textView.text;
}
(assuming that myString
is a property of your delegate)
If the variable myString
is an NSString* variable, you just need to call the following assignment once:
myString = textView.text;
Then myString
points to textView.text
.
myString.String = textView.text;
精彩评论