Search code examples
multithreadingioscore-text

Using iOS CoreText APIs that don't use a CGContextRef in a non-main Thread


The iOS APIs don't mention threading restrictions on CoreText APIs. To what extent are they safe to use on non-main threads when calling functions that don't use a CGContextRef?

Specifically, I'm trying to create a bunch of NSAttributedStrings using a custom truncation algorithm, and I'd like to be able to background the work. I'm only using:

CTLineCreateWithAttributedString
CTLineGetTypographicBounds
CTLineGetStringIndexForPosition

Solution

  • I should have checked <CoreText/CoreText.h>.

    /*!
        @header
    
        Thread Safety Information
    
        All functions in this header are thread safe unless otherwise specified.
    */