• 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
Shared NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shared NSTextView


  • Subject: Shared NSTextView
  • From: "Oleg Krupnov" <email@hidden>
  • Date: Tue, 19 Aug 2008 07:46:24 +0300

I am developing a custom view, sort of a simple graphic editor, where
the user can draw graphic boxes of different size. Each box should
display its own attributed string bounded by its own size, and when
the user double-clicks any box, he becomes able to edit the box's text
in-place.

I have read the docs and have a general understanding of the text
system components: NSTextStorage, NSLayoutManager, NSTextContainer and
NSTextView.

However I wonder if some instances of these can be shared across
different graphic boxes for better efficiency?

I could go the simple and dull way and create a separate instance of
NSTextView for each box, but I am afraid this could be a waste of
resources, because layout manager is costy. Also, most of time I only
need to display text in boxes, not to edit it.

I thought it could be smarter to create a single shared instance of
NSTextView per custom view, and re-attach it to different boxes when
the user double-clicks a box. The rest of time I'd use NSTextStorage
and NSTextContainer to just draw the string. Is this a good idea? In
this case, what object instances should each graphic box have of its
own? My guess is that each graphic box should have its own instances
of NSTextStorage and NSTextContainer, but I am not sure what about
NSLayoutManager? Can it be shared too, or it's going to be
inefficient? How do I reconnect the shared components from a box to
another box?

Thanks.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Shared NSTextView
      • From: Douglas Davidson <email@hidden>
    • Re: Shared NSTextView
      • From: chaitanya pandit <email@hidden>
    • Re: Shared NSTextView
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: How to write a string to a file
  • Next by Date: NSView confusion
  • Previous by thread: Re: How to write a string to a file
  • Next by thread: Re: Shared NSTextView
  • Index(es):
    • Date
    • Thread