views:

50

answers:

2

I want to have a screen in my app that shows real-time log information - e.g. a scrolling list of textual strings. Previously I've seen people just use a textview and append new log entries to the list - it seems this may be not so efficient, especially when the list becomes long. Is there any sample code out there that can efficiently show real-time text log information? Or does everyone just write their own using a tableview?

Thanks

A: 

If you're building your own, perhaps you could use a deque of UITextView instances, adding to the end of the queue and removing from the front, only buffering a constant number of instances.

You could perhaps feed the deque to a UIView that contains the text views as subviews, with various offsets set based on how many lines your application is displaying at one time.

Alex Reynolds
+2  A: 

UITableView would be the way to go here, and using the deque idea Alex mentioned above, just call insertRowsAtIndexPaths:withRowAnimation: and deleteRowsAtIndexPaths:withRowAnimation: as you push/pop log entries onto your deque.

drewh
Was going to say the same thing. You might also use a fixed-width font so you can more easily determine the necessary row height, or you could display one truncated line and use a detail disclosure indicator sort of scheme to display the whole log entry.
Nimrod
thanks - this seems like a good idea. I'll give it a go :-)
Ben Clayton