开发者

How do you automatically update a string variable when a user types in a UITextView?

开发者 https://www.devze.com 2023-04-08 02:15 出处:网络
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 do

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号