Swiftpack.co - ChimeHQ/TextStory as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Happier, more flexible NSTextStorage
.package(url: "https://github.com/ChimeHQ/TextStory.git", from: "0.4.2")

Github CI Carthage compatible


TextStory is a small set of classes and protocols for easier work with NSTextStorage and associated systems. iOS and macOS are supported.


Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/ChimeHQ/TextStory")


github "ChimeHQ/TextStory"


A minimal NSTextStorage subclass that provides hooks for much more powerful delegate behavior. Great for separating logic/behavior from your storage object. Because it is built to wrap another NSTextStorage instance, it is more easily composable.

Unfortunately, to date I've not been able to figure out a way to build this class in Swift. If you have experience working with NSTextStorage and Swift/ObjC automatic NSString/String bridging, I'd love to hear from you.

- (void)textStorage:(TSYTextStorage *)textStorage willReplaceCharactersInRange:(NSRange)range withString:(NSString *)string;
- (void)textStorage:(TSYTextStorage *)textStorage didReplaceCharactersInRange:(NSRange)range withString:(NSString *)string;
- (void)textStorageProcessEditingComplete:(TSYTextStorage *)textStorage;

// available for macOS only
- (NSRange)textStorage:(TSYTextStorage *)textStorage doubleClickRangeForLocation:(NSUInteger)location;
- (NSUInteger)textStorage:(TSYTextStorage *)textStorage nextWordIndexFromLocation:(NSUInteger)location direction:(BOOL)forward;


An NSTextStorage subclass that maintains a history of text changes with low memory and performance overhead. This class makes it possible to decouple text change processing from them Cocoa text display system, making them asynchronous with respect to each other. Very useful for keeping your UI fast and responsive even if the processing of changes can be slow.

// interact with the buffered view of text
func bufferedSubstring(from range: NSRange) -> String
var bufferedLength: Int

// commit one change in the queue, allowing precise control over how the buffered view changes
func applyNextChange()


A simple protocol that abstracts string storage. This is very useful for standardizing behavior across NSTextStorage, NSTextView and other objects you may use for text manipulation. Particularly handy for testing and decoupling systems from Apple's classes behaviors/APIs.


Standard interface for systems that need to observe and react to changes in a TextStoring instance.


A concrete TextStoringMonitor class that implements progressive, on-demand access to a wrapped TextStoringMonitor. This makes it easy to add lazy semantics on top of an existing TextStoringMonitor, which can be very helpful for handling large documents.


An easy way to group together a collection of TextStoringMonitor instances and tread them as a single unit.

Suggestions or Feedback

We'd love to hear from you! Get in touch via twitter, an issue, or a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


Stars: 56
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.


Release Notes

1 week ago
  • Fix a nasty bug related to computing the minimum disclosure ranges in LazyTextStoringMonitor

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics