Why Apple’s SimpleTextInput sample code is inefficient
Asked Answered
F

2

6

I’m looking at Apple’s SimpleTextInput sample code, which is a sample project for an iOS text editor that uses Core Text to display the text. This is a wonderful thing.

But its ReadMe document says:

This sample code should not be considered a template for a text editor, but rather as an example of how to bind the text input system to a pre-existing text editor. The project's use of CoreText is naive and inefficient; it deals only with left-to-right text layout, and it is by no means a good template for any text editor. It is a implementation meant only to illustrate how to bind the system keyboard (that is, the text input system) to some pre-existing text editor.

I’m curious as to how this text editor is inefficient. Is it something fundamental in its design? Is it something that simple tweaks could improve? UITextView might have really elaborate caching algorithms hidden in it; so, would the problem be that SimpleTextInput lacks them?

Folberth answered 30/10, 2011 at 16:32 Comment(0)
S
3

Apple’s SimpleTextInput sample code, uses Draw text all at once in single CTFrameRef object: This is the simplest options as you can get core text to just draw everything in one block. The only downside of this is that it can be inefficient as recreating CTFrameRef on every keystroke and redrawing all the text every time it is edited will slow your app down especially if there is a lot of text plus a lot of attributes.

For more efficient ways of implementing Core text editor read Rich Text Editing : The choices topic:Draw line by line.

Spike answered 13/3, 2013 at 12:51 Comment(0)
D
0

I have seen it, It does not implement all methods, may be that is the reason they are saying it. Depends on your project and need, you can use and expand it.

Danialah answered 7/9, 2012 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.