<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A2 Apps &#187; NSString</title>
	<atom:link href="http://a2apps.com.au/tag/nsstring/feed/" rel="self" type="application/rss+xml" />
	<link>http://a2apps.com.au</link>
	<description></description>
	<lastBuildDate>Sun, 10 Mar 2013 08:52:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Remove leading and trailing spaces</title>
		<link>http://a2apps.com.au/remove-leading-and-trailing-spaces/</link>
		<comments>http://a2apps.com.au/remove-leading-and-trailing-spaces/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 08:52:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=111</guid>
		<description><![CDATA[Removing start and end spaces of an NSString is very simple:]]></description>
				<content:encoded><![CDATA[<p>Removing start and end spaces of an NSString is very simple:</p>
<pre class="brush: objc; title: ; notranslate">

NSString* result = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

</pre>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/remove-leading-and-trailing-spaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting an integer in a string into an NSNumber</title>
		<link>http://a2apps.com.au/converting-an-integer-in-a-string-into-an-nsnumber/</link>
		<comments>http://a2apps.com.au/converting-an-integer-in-a-string-into-an-nsnumber/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 02:14:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[NSNumber]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=108</guid>
		<description><![CDATA[This new idiom is concise and clean:]]></description>
				<content:encoded><![CDATA[<p>This new idiom is concise and clean:</p>
<pre class="brush: objc; title: ; notranslate">
NSNumber* intNumber = @([str intValue]);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/converting-an-integer-in-a-string-into-an-nsnumber/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSMutableString to NSString</title>
		<link>http://a2apps.com.au/nsmutablestring-to-nsstring/</link>
		<comments>http://a2apps.com.au/nsmutablestring-to-nsstring/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 01:24:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[NSMutableString]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=101</guid>
		<description><![CDATA[Method 1, making a copy: Method 2, also making a copy: Method 3, passing the original mutable string as an NSString by casting (almost never used):]]></description>
				<content:encoded><![CDATA[<p>Method 1, making a copy:</p>
<pre class="brush: objc; title: ; notranslate">

NSString* str = [mutableStr copy];

</pre>
<p>Method 2, also making a copy:</p>
<pre class="brush: objc; title: ; notranslate">

NSString* str = [NSString stringWithString:mutableStr];

</pre>
<p>Method 3, passing the original mutable string as an NSString by casting (almost never used):</p>
<pre class="brush: objc; title: ; notranslate">

NSString* immutableRefToMutableString = (NSString*)mutableStr;

</pre>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/nsmutablestring-to-nsstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily testing if a string is nil or empty</title>
		<link>http://a2apps.com.au/easily-testing-if-a-string-is-nil-or-empty/</link>
		<comments>http://a2apps.com.au/easily-testing-if-a-string-is-nil-or-empty/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 13:16:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[Idioms]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=95</guid>
		<description><![CDATA[A very common idiom: Works because calling a method on nil is not an error &#8211; just silently returns nil, which is also false.]]></description>
				<content:encoded><![CDATA[<p>A very common idiom:</p>
<pre class="brush: objc; title: ; notranslate">

if ([string length]) {

// It's a string of at least one char, and is not null.

}
</pre>
<p>Works because calling a method on nil is not an error &#8211; just silently returns nil, which is also false.</p>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/easily-testing-if-a-string-is-nil-or-empty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Helper method to convert an NSDate to string</title>
		<link>http://a2apps.com.au/helper-method-to-convert-an-nsdate-to-string/</link>
		<comments>http://a2apps.com.au/helper-method-to-convert-an-nsdate-to-string/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 12:58:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[NSDate]]></category>
		<category><![CDATA[NSDateFormatter]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=83</guid>
		<description><![CDATA[For performance reasons we only create the formatter object once, and just reuse it afterwards. The formatter style can be easily tailored by duplicating the method and changing its options; we keep the method&#8217;s name as descriptive as possible of the conversion to be done. It is also a good idea to keep this in <a class="read-more-link" href="http://a2apps.com.au/helper-method-to-convert-an-nsdate-to-string/"><br />...read more</a>]]></description>
				<content:encoded><![CDATA[<p>For performance reasons we only create the formatter object once, and just reuse it afterwards. The formatter style can be easily tailored by duplicating the method and changing its options; we keep the method&#8217;s name as descriptive as possible of the conversion to be done. It is also a good idea to keep this in a category on NSString.</p>
<pre class="brush: objc; title: ; notranslate">

+ (NSString*)dateAsFullDateTime:(NSDate*)date;
{
  static NSDateFormatter * formatter = nil;
  if (formatter == nil) {
    formatter = [[NSDateFormatter  alloc] init];
    [formatter setDateStyle:NSDateFormatterFullStyle];
    [formatter setTimeStyle:NSDateFormatterLongStyle];
    [formatter setDoesRelativeDateFormatting:NO];
  }
  return [formatter stringFromDate:date];
}

</pre>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/helper-method-to-convert-an-nsdate-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>URL Encoding an NSString</title>
		<link>http://a2apps.com.au/url-encoding-an-nsstring/</link>
		<comments>http://a2apps.com.au/url-encoding-an-nsstring/#comments</comments>
		<pubDate>Tue, 26 Feb 2013 12:53:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS Snippets]]></category>
		<category><![CDATA[NSString]]></category>

		<guid isPermaLink="false">http://a2apps.com.au/?p=78</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<pre class="brush: objc; title: ; notranslate">

+ (NSString*)urlEncodeString:(NSString*)str;

{

return (__bridge_transfer NSString *)

CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)str, NULL,
   (CFStringRef)@&quot;!*'();:@&amp;=+$,/?%#[ ]&quot;, kCFStringEncodingUTF8);

}

</pre>
]]></content:encoded>
			<wfw:commentRss>http://a2apps.com.au/url-encoding-an-nsstring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
