• 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
Truncating start and end of attributed string to show desired range.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Truncating start and end of attributed string to show desired range.


  • Subject: Truncating start and end of attributed string to show desired range.
  • From: Kenneth Baxter <email@hidden>
  • Date: Thu, 03 Mar 2011 02:49:43 +0000 (GMT)

Hi, I'm displaying search results in an outine view, and want to show the portion of the text where the search term was found, by truncating both the start and end of the string (where necessary) so that the result is visible in the displayed portion of the string. I can see how to truncate at the head or tail or center using the built in truncation options, but nothing to give a range of characters I want visible and get it to truncate before and after where necessary.

I know enough about the string measurement stuff to be able to come up with an algorithm myself, but it would probably take a lot of work, when it may well already be a solved problem.

I tried searching for something that would do the trick, but didn't come up with anything.

Is there something already available that would take an attributed string, and the range you want visible and a rectangle (or size) to fit it in, and return a modified attributed string which will fit in that size, with ellipses at the start and/or end as required so that the required range is visible?

Thanks

Ken
_______________________________________________

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


  • Prev by Date: Re: Editing a list of NSMutableStrings
  • Next by Date: table view and custom cell optimization problem
  • Previous by thread: Getting Playlist title for a specific media collection (iOS)
  • Next by thread: table view and custom cell optimization problem
  • Index(es):
    • Date
    • Thread