nicklockwood/iConsole

Maximum length of NSString in UITextView console

Opened this issue · 2 comments

Any thoughts about how to overcome the limitations of appending NSStrings on the consoles UITextView? When we log significant info, we crash as the NSString can't be appended any further.

I'm thinking that an alternative would be to use a UIWebView and use a stream to bring the text into the web view as the log messages come in.

I wasn't aware that there was such a limitation - the length of a string is defined as a NSUInteger, so I would have expected it to support up to 4GB of text. Do you know what the actual limit is?

UIWebView would be an option I suppose, although that has performance issues of its own. Another option would be to use a table view, but that would mean implementing some fairly complex logic to handle text wrapping.

I don't know the limitation but it seemed a lot less than 4gb. We were logging some heavy network requests and responses and it killed over after about 10 mins. If guess it was maybe 150-200MB. More than most would normally log so I'm pretty sure this is an edge case.

The table view idea is a good one I hadn't considered. Core data can store tons of crap. If every log statement is a row, a fetched request controller would easily manage the memory and fetch a few at a time so its fast, as well as update automatically with new logs as they come in.

Auto Layout could help take care of text wrapping -- set the max preferred width on the label, number of lines to 0, then use intrinsicContentSize to give the height of the text. Sweet!!!

G

Sent from my iPhone.

On Jul 20, 2013, at 2:00 PM, Nick Lockwood notifications@github.com wrote:

I wasn't aware that there was such a limitation - the length of a string is defined as a NSUInteger, so I would have expected it to support up to 4GB of text. Do you know what the actual limit is?

UIWebView would be an option I suppose, although that has performance issues of its own. Another option would be to use a table view, but that would mean implementing some fairly complex logic to handle text wrapping.


Reply to this email directly or view it on GitHub.