Write to TextView overlays previous write
I have a TextView created in IB... I have two "paragraphs" I want to write, which appear to work, with the exception of the 2nd write overlays the first.
How do I fix this?
First write:
resultText.text =[NSString stringW开发者_运维知识库ithFormat:@"Decode Data: %@, \n%@\n\n",symbol.data, symbol.typeName]; // display it...
2nd write:
resultText.text = [NSString stringWithFormat:@"\nDatabase: \n%@ \n%@ \n%@",
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]];
It looks to me like you're just assigning the text twice, instead of appending. An easy way to fix that would be to change your 2nd write to:
resultText.text = [NSString stringWithFormat:@"%@\nDatabase: \n%@ \n%@ \n%@",
resultText.text,
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]];
That will keep the previous text you had there.
EDIT:
resultText.text =[NSString stringWithFormat:@"Decode Data: %@, %@",symbol.data, symbol.typeName];
resultText.text = [NSString stringWithFormat:@"%@\nDatabase: %@, %@, %@",
resultText.text,
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)],
[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]];
精彩评论