• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSLayoutManager and NSTextView problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSLayoutManager and NSTextView problems


  • Subject: NSLayoutManager and NSTextView problems
  • From: Rob Minerick <email@hidden>
  • Date: Fri, 21 Nov 2003 14:11:20 -0600

What I'm trying to do is have a table which one can select different entries and have the content of those entries show up in a text view, similar to what Mail.app does. However, in addition to the content showing up in the text view in the main window, I'd also like the content to show up in a new window if the entry in the table view is double clicked. So, I have no problem here, everything works as expected when the entry is double clicked and the NSTextStorage instance is shared between the two text views (one in the main window, one in the newly created window). However, when I change the selection in the table view and try to change the layoutManager of the main window's NSTextView to use a new instance of NSTextStorage, I get the following error (or similar, over and over):

*** Assertion failure in -[NSMutableRLEArray objectAtIndex:effectiveRange:], String.subproj/NSAttributedString.m:1009

Here is the pertinent part of what I'm doing to open a new window which shares the NSTextStorage with the main window:


VMJournalEntryWindowController *wc = [[VMJournalEntryWindowController alloc]
initWithWindowNibName:@"JournalEntryEditor"];
NSLayoutManager *mainLayoutManager = [[_ctl journalEntryTextView] layoutManager], *layoutManager;

[wc showWindow:self];
wcTextStorage = [[wc entryTextView] textStorage];
wcLayoutManager = [[wc entryTextView] layoutManager];

[wcTextStorage beginEditing];
[wcTextStorage setAttributedString:RTFD];
[wcTextStorage endEditing];

[wcTextStorage addLayoutManager:mainLayoutManager];


RTFD is an NSMutableAttributedString which I left out for brevity, _ctl is the main window's controller.

Then, when I change the selection in the table view, the following is executed to point the main window to a different instance of NSTextStorage:


NSTextStorage *sharedTextStorage = [[wc entryTextView] textStorage];
NSLayoutManager *mainLayoutManager = [[_ctl journalEntryTextView] layoutManager];
NSTextStorage *newTS = [[NSTextStorage alloc] init];

[sharedTextStorage removeLayoutManager:mainLayoutManager];
[newTS addLayoutManager:mainLayoutManager];


wc is a pointer to the previously created editor, _ctl is the main window's controller. This is being called from the NSTableView's tableViewSelectionDidChange delegate.


I *must* be missing something about the interactions among the different objects that make up the text architecture, but I've read and re-read everything I can find in Apple's docs and the various books I have - and I simply can't figure this out. Any ideas? Thanks...

--
Rob Minerick
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSLayoutManager and NSTextView problems
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re-Post: Dragging out of an NSBrowser
  • Next by Date: copying an object instance using NSCopyMemoryPages
  • Previous by thread: Re: Re-Post: Dragging out of an NSBrowser
  • Next by thread: Re: NSLayoutManager and NSTextView problems
  • Index(es):
    • Date
    • Thread