Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3398470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:39:11+00:00 2026-05-18T04:39:11+00:00

I have an NSTextView backed by a text system I put together myself, along

  • 0

I have an NSTextView backed by a text system I put together myself, along the lines of the “Assembling the Text System by Hand” section in the Text System Overview in the Cocoa documentation. It successfully displays the contents of the NSTextStorage on the screen.

But when I type into it, nothing seems to happen—the text on screen doesn’t change. If I select the text, the shape of the selection suggests that the text has changed. If I copy and paste the text into TextEdit, I can even see my edits. And if I type enough, I can get it to throw an exception:

NSRunStorage, _NSBlockNumberForIndex(): index (5897) beyond array bounds (5881)

Golly, this looks like the kind of thing I could spend the better part of a day debugging. What’s going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:39:12+00:00Added an answer on May 18, 2026 at 4:39 am

    Make sure you connected the NSTextStorage to the NSLayoutManager like this:

    [textStorage addLayoutManager:layoutManager];
    

    Instead of like this:

    [layoutManager setTextStorage:textStorage];   //BAD
    

    The documentation on -[NSLayoutManager setTextStorage:] says that it should never be called directly, only overridden. Apparently this is the reason. Hopefully I saved you hours and hours of fruitless work!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSTextView where i put the delegate to my file owner. My
I have an NSTextView in an NSScrollView , and I am programmatically inserting an
I'm working with a NSTextView and have a delegate set for its -textStorage property.
I have a pretty simple window that contains an NSTextView. I'm calling readRTFDFromFile: to
I want to print out the Text contents of a NSTextView using the NSLog
I'm setting up an NSTextView programmatically: NSTextView *infoTextView = [[NSTextView alloc] initWithFrame:insetRect]; [infoTextView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
Using an action I'm setting an NSTextView object with a specific string. For example:
(This question has been rewritten from an issue with NSTextView following some further research)
I want to find something that is the equivalent of [fieldName stringValue] for NSTextField,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.