I have a UITextView that is called DictionaryConsole
. Every 0.05 seconds, text is being set to it based on the following switch statement:
switch ((DictionaryLine*100)/NumberofWordsTilEnd) {
case 10:
NewLine = [NSString stringWithFormat: @"Attack is Now 10 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 25:
NewLine = [NSString stringWithFormat: @"Attack is Now 25 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 50:
NewLine = [NSString stringWithFormat: @"Attack is Now 50 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 75:
NewLine = [NSString stringWithFormat: @"Attack is Now 75 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 80:
NewLine = [NSString stringWithFormat: @"Attack is Now 80 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 90:
NewLine = [NSString stringWithFormat: @"Attack is Now 90 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
case 95:
NewLine = [NSString stringWithFormat: @"Attack is Now 95 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
case 98:
NewLine = [NSString stringWithFormat: @"Attack is Now 98 Percent Complete"];
NewLine2 = [NewLine stringByAppendingString:@"\n"];
DictionaryConsole.text = [NewLine2 stringByAppendingString:DictionaryConsole.text];
break;
default:
break;
}
This is the NSTimer
:
Dictionary = [NSTimer scheduledTimerWithTimeInterval:0.05
target:self
selector:@selector(DictionaryAttack)
userInfo:nil
repeats:YES];
Every time -(void)DictionaryAttack
is called, that switch statement gets executed. Dictionary Line
is an int that is increased by 1 in -(void)DictionaryAttack
. The strings go to the DictionaryConsole
(UITextView
) with no problem. But my problems is 33 of the NewLine
string is "printed" to the text view. However, I would only like one string to be "printed". What did I do wrong?