• 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
Re: Truncating strings to fit a text field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Truncating strings to fit a text field


  • Subject: Re: Truncating strings to fit a text field
  • From: Satoshi Matsumoto <email@hidden>
  • Date: Fri, 26 Mar 2004 13:31:07 +0900

Hi Mark,

on 04.3.26 0:50 PM, Mark Alldritt at email@hidden wrote:
> I want to display a file path in a NSTextField instance. I want to truncate
> a long file path with a ... (like I can do in Carbon with
> TruncString/TruncText). What's the magic incantation to make this happen in
> Cocoa?
>
> There is NSString's sizeWithAttributes, but I don't see anything that will
> "do the right thing" given an available width.

I don't know whether the system truncate routine exists in Cocoa, but this
is my own truncate code for a long path.

truncName = [NSString stringWithFormat:@"%@ - .../%@",
[path lastPathComponent],
[[path stringByDeletingLastPathComponent] lastPathComponent]];

Satoshi
-----------------------------------------------------
Satoshi Matsumoto <email@hidden>
816-5 Odake, Odawara, Kanagawa, Japan 256-0802
_______________________________________________
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: Truncating strings to fit a text field
      • From: Ryan Stevens <email@hidden>
References: 
 >Truncating strings to fit a text field (From: Mark Alldritt <email@hidden>)

  • Prev by Date: Re: Scale and convert image to JPEG using NSImage, NSImageRep, etc?
  • Next by Date: Re: NSTableView
  • Previous by thread: Truncating strings to fit a text field
  • Next by thread: Re: Truncating strings to fit a text field
  • Index(es):
    • Date
    • Thread