I'm trying to implement a simple char count of an UITextView while the user is typing in text (i.e. it should update continuously).
I have two problems.
(1) The first is that I don't know in which method I should put my charCount method. textViewShouldBeginEditing doesn't work, as it simply asks if an editing session should begin. textView:shouldChangeTextInRange doesn't work either, as it again asks if it is permitted to begin editing. I couldn't find other useful methods in the Apple doc.
(2) Next problem: I tried to call my charCount method from within another method. But I get the compiler error: 'ViewController' may not respond to 'charCount'.
Here is my humble attempt:
- (IBAction)charCount:(id)sender {
// all chars
int charsAsInt = (int)(textView.text.length);
NSString *newText = [[NSString alloc] initWithFormat:@"All chars: %d", charsAsInt];
allCharacters.text = newText;
[newText release];}
- (BOOL)textViewShouldBeginEditing:(UITextView *)aTextView {
[self charCount];}
I guess it has to do with me trying to call a IBAction defined method that this won't work. But what would be the proper way to call a IBAction method from within a non-IBAction method?
As always, I'm sorry for these very basic questions and I do appreciate every little help to get my beginner's mind around this.