Re: Truncating strings to fit a text field
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.