For a plain text (not rich text/RTF) NSTextView, I found that: Since NSTextView doesn’t understand the NSPasteboard.PasteboardType.string pasteboard type for reading or writing, I tried two approaches to handle plain text input (pasting) and output (cut/copy): The backport seems to work, but extending supported types sounds like more robust solution.
NSTextStorage provides attribute fixing of user-entered text, via NSMutableAttributedString.fixAttributes(in:). Attribute fixing… NSMutableAttributedString.fixAttributes(in:) always work on full paragraph ranges. It extends the passed-in range as needed “to cover the last paragraph partially contained”.
The metaphor of the “black box” is very common in programming. It is so general that it’s nearly meaningless; but it summarizes a lot of specialized principles nicely and shows a unifying principle. A black box is characterized by: It can be applied to “modules” on all levels of abstraction.
Here’s a short definition of the two terms: Cohesion is about how well elements within a module belong together and serve a common purpose. Coupling is about how much one module depends or interacts with other modules. Thus, cohesion is an intra-module concern whereas coupling cuts across modules [aka inter-module].
When you work with NSTextView and happen to use insertText(_:) to programmatically insert text, you get an undoable action for free. This might give the impression you get undo/redo functionality for free. Eventually, you’ll notice how other changes don’t have an affordance in the “Edit” menu. While it’s possible to get “Undo Typing” and “Undo Set Color” from some function calls, it’s not possible to get “Undo Change Text Attributes” when you use NSTextStorage.addAttributes(_:range:).
Reactive, declarative code is sequentially cohesive: you have a sequence of events and reactions to events, and it’s pieces are tied together real close. The processing chain itself is then a function or feature of the app. The chain of operators is a thing itself; the step-by-step transformation is then reified into a sequence in one place: it has a beginning, an end, a sequential order of steps.
Thanks everyone for joining the AMA yesterday! Was a fun experience :) We talked about a couple of technical and historic things. Here’s an outline of the pieces: The first, very successful two weeks of sale having passed, this adds up to a whopping $1.03 hourly rate! I sold the app 181 times […].