<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Truncate a String and Append an Ellipsis, Respecting the Font Size</title>
	<atom:link href="http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html</link>
	<description>iOS Developer Tips, Tricks and Tutorials.</description>
	<lastBuildDate>Wed, 08 Feb 2012 06:31:16 -0600</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: phait</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-38584</link>
		<dc:creator>phait</dc:creator>
		<pubDate>Tue, 25 Jan 2011 06:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-38584</guid>
		<description>how would you do the same thing for multiple lines where the ellipsis is only added to the last line?</description>
		<content:encoded><![CDATA[<p>how would you do the same thing for multiple lines where the ellipsis is only added to the last line?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: berec</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-31026</link>
		<dc:creator>berec</dc:creator>
		<pubDate>Wed, 10 Nov 2010 14:01:32 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-31026</guid>
		<description>Hello. Thank you for that. Is there any way to truncate multiline text? I mean  adding to your category method like - (NSString*)stringByTruncatingToSize:(CGSize)size withFont:(UIFont *)font; Is it possible?
Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hello. Thank you for that. Is there any way to truncate multiline text? I mean  adding to your category method like &#8211; (NSString*)stringByTruncatingToSize:(CGSize)size withFont:(UIFont *)font; Is it possible?<br />
Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krille</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-21375</link>
		<dc:creator>Krille</dc:creator>
		<pubDate>Tue, 27 Jul 2010 12:18:06 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-21375</guid>
		<description>Great - thank you very much, everytime I learn something new from your articles!</description>
		<content:encoded><![CDATA[<p>Great &#8211; thank you very much, everytime I learn something new from your articles!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-21374</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Tue, 27 Jul 2010 12:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-21374</guid>
		<description>Krille, thanks for pointing that out. I&#039;ve updated the code to check for the string length up front.</description>
		<content:encoded><![CDATA[<p>Krille, thanks for pointing that out. I&#8217;ve updated the code to check for the string length up front.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krille</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-21369</link>
		<dc:creator>Krille</dc:creator>
		<pubDate>Tue, 27 Jul 2010 10:10:18 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-21369</guid>
		<description>Thank you for this post!
I have a problem with this implementation: Strings are cut, even if they are narrower
than the defined maximum width:

Example:
cell.textLabel.text = [news stringByTruncatingToWidth:240 withFont:[UIFont boldSystemFontOfSize:15]];

So every String is at least missing the last character and gets the ellipsis appended...

&quot;Here is a superlong Title to...&quot; -&gt; correct
&quot;Short Titl...&quot; -&gt; wrong

Cheers
Krille</description>
		<content:encoded><![CDATA[<p>Thank you for this post!<br />
I have a problem with this implementation: Strings are cut, even if they are narrower<br />
than the defined maximum width:</p>
<p>Example:<br />
cell.textLabel.text = [news stringByTruncatingToWidth:240 withFont:[UIFont boldSystemFontOfSize:15]];</p>
<p>So every String is at least missing the last character and gets the ellipsis appended&#8230;</p>
<p>&#8220;Here is a superlong Title to&#8230;&#8221; -&gt; correct<br />
&#8220;Short Titl&#8230;&#8221; -&gt; wrong</p>
<p>Cheers<br />
Krille</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-21283</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Mon, 26 Jul 2010 14:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-21283</guid>
		<description>Michelle, the docs state &quot;If you are using managed memory (not garbage collection), this method retains the new object before returning it.&quot; so the autorelease should do the trick...</description>
		<content:encoded><![CDATA[<p>Michelle, the docs state &#8220;If you are using managed memory (not garbage collection), this method retains the new object before returning it.&#8221; so the autorelease should do the trick&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michelle</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/truncate-an-nsstring-and-append-an-ellipsis-respecting-the-font-size.html#comment-21282</link>
		<dc:creator>Michelle</dc:creator>
		<pubDate>Mon, 26 Jul 2010 14:20:48 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=6737#comment-21282</guid>
		<description>Does NSString mutableCopy really return a string that needs to be released?  By standard naming conventions, it should not.

You might want to generalize the string to be appended.

- (NSString*)stringByTruncatingStringToWidth:(CGFloat)width withFont:(UIFont *)font endingWith:(NSString*)endString {  /* your implementation but using endString */ }

and implement your function as

- (NSString*)stringByTruncatingStringToWidth:(CGFloat)width withFont:(UIFont *)font
{
   [self stringByTruncatingStringToWidth: width withFont: font endingWith: ellipsis];
}

But that&#039;s just a small tweak.</description>
		<content:encoded><![CDATA[<p>Does NSString mutableCopy really return a string that needs to be released?  By standard naming conventions, it should not.</p>
<p>You might want to generalize the string to be appended.</p>
<p>- (NSString*)stringByTruncatingStringToWidth:(CGFloat)width withFont:(UIFont *)font endingWith:(NSString*)endString {  /* your implementation but using endString */ }</p>
<p>and implement your function as</p>
<p>- (NSString*)stringByTruncatingStringToWidth:(CGFloat)width withFont:(UIFont *)font<br />
{<br />
   [self stringByTruncatingStringToWidth: width withFont: font endingWith: ellipsis];<br />
}</p>
<p>But that&#8217;s just a small tweak.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

