<?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: Does a NSString contain a substring ?</title>
	<atom:link href="http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/feed/" rel="self" type="application/rss+xml" />
	<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/</link>
	<description>Coding under the Hammer</description>
	<lastBuildDate>Mon, 07 Jun 2010 12:36:06 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-513</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Fri, 19 Feb 2010 19:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-513</guid>
		<description>Hi Susan

Something like the following (as a category on NSString):


- (BOOL)doesContainSubstring:(NSString *)substring{

	//If self or substring have 0 length they cannot match
	//This can have odd results with NSRange
	if([self length] == 0 &#124;&#124; [substring length] == 0)
		return NO;


	NSRange textRange;

	textRange = [[self lowercaseString] rangeOfString:[substring lowercaseString]];

	if(textRange.location != NSNotFound)
	{
		return YES;
	}else{
		return NO;
	}


}</description>
		<content:encoded><![CDATA[<p>Hi Susan</p>
<p>Something like the following (as a category on NSString):</p>
<p>- (BOOL)doesContainSubstring:(NSString *)substring{</p>
<p>	//If self or substring have 0 length they cannot match<br />
	//This can have odd results with NSRange<br />
	if([self length] == 0 || [substring length] == 0)<br />
		return NO;</p>
<p>	NSRange textRange;</p>
<p>	textRange = [[self lowercaseString] rangeOfString:[substring lowercaseString]];</p>
<p>	if(textRange.location != NSNotFound)<br />
	{<br />
		return YES;<br />
	}else{<br />
		return NO;<br />
	}</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Susan</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-512</link>
		<dc:creator>Susan</dc:creator>
		<pubDate>Fri, 19 Feb 2010 05:11:38 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-512</guid>
		<description>I&#039;ll use that code A LOT.
  
How would I make it into a Category and just make it a part of NSString everywhere?</description>
		<content:encoded><![CDATA[<p>I&#8217;ll use that code A LOT.</p>
<p>How would I make it into a Category and just make it a part of NSString everywhere?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-511</link>
		<dc:creator>Robert</dc:creator>
		<pubDate>Tue, 09 Feb 2010 14:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-511</guid>
		<description>You posted this 10 months ago and it&#039;s still helping people. Thanks for the information.</description>
		<content:encoded><![CDATA[<p>You posted this 10 months ago and it&#8217;s still helping people. Thanks for the information.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jose</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-496</link>
		<dc:creator>jose</dc:creator>
		<pubDate>Sun, 20 Dec 2009 15:11:41 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-496</guid>
		<description>@frank, you need to chill dawg. just because you dont like (or know) something doesnt mean it sucks. different strokes for different folks.</description>
		<content:encoded><![CDATA[<p>@frank, you need to chill dawg. just because you dont like (or know) something doesnt mean it sucks. different strokes for different folks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-484</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Wed, 16 Sep 2009 18:34:56 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-484</guid>
		<description>To say it is a bit messed up is a bit extreme :)

Its different, and I expect a lot of people prefer it to C/C++, myself included.</description>
		<content:encoded><![CDATA[<p>To say it is a bit messed up is a bit extreme <img src='http://objcolumnist.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Its different, and I expect a lot of people prefer it to C/C++, myself included.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frankSinatra</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-483</link>
		<dc:creator>frankSinatra</dc:creator>
		<pubDate>Wed, 16 Sep 2009 18:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-483</guid>
		<description>crisbetewsky, pity!what pity! probably because Obj-C sucks big time. People in Apple are so stupid not to use just C/C++ instead of this messed up language obj-C. (-) (+) before function call waiting for some typos and headaches.</description>
		<content:encoded><![CDATA[<p>crisbetewsky, pity!what pity! probably because Obj-C sucks big time. People in Apple are so stupid not to use just C/C++ instead of this messed up language obj-C. (-) (+) before function call waiting for some typos and headaches.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CrisBetewsky</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-25</link>
		<dc:creator>CrisBetewsky</dc:creator>
		<pubDate>Mon, 06 Jul 2009 19:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-25</guid>
		<description>Some of us even don&#039;t realize the importance of this information. What a pity.</description>
		<content:encoded><![CDATA[<p>Some of us even don&#8217;t realize the importance of this information. What a pity.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KattyBlackyard</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-8</link>
		<dc:creator>KattyBlackyard</dc:creator>
		<pubDate>Mon, 15 Jun 2009 05:58:12 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-8</guid>
		<description>Hi, very nice post. I have been wonder&#039;n bout this issue,so thanks for posting</description>
		<content:encoded><![CDATA[<p>Hi, very nice post. I have been wonder&#8217;n bout this issue,so thanks for posting</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spencer MacDonald</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-5</link>
		<dc:creator>Spencer MacDonald</dc:creator>
		<pubDate>Sat, 30 May 2009 08:54:11 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-5</guid>
		<description>A very valid point Vincent.

For the people that are new to Objective-C it is important to mention that messages sent to an object that is nil, are simply ignored. But in the example above the rest of the code will still run with NSRange being undefined.</description>
		<content:encoded><![CDATA[<p>A very valid point Vincent.</p>
<p>For the people that are new to Objective-C it is important to mention that messages sent to an object that is nil, are simply ignored. But in the example above the rest of the code will still run with NSRange being undefined.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Gable</title>
		<link>http://objcolumnist.com/2009/04/12/does-a-nsstring-contain-a-substring/comment-page-1/#comment-4</link>
		<dc:creator>Vincent Gable</dc:creator>
		<pubDate>Fri, 29 May 2009 08:03:21 +0000</pubDate>
		<guid isPermaLink="false">http://objcolumnist.com/?p=36#comment-4</guid>
		<description>Unfortunately, if &lt;code&gt;string&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;, then &lt;code&gt;-rangeOfString:&lt;/code&gt; is going to give you an undefined value, especially on iPhone. You probably want to check that &lt;code&gt; string != nil&lt;/code&gt; before calling &lt;code&gt;-rangeOfString:&lt;/code&gt;.  &lt;a href=&quot;http://vgable.com/blog/2009/04/19/beware-rangeof-nsstring-operations/&quot; rel=&quot;nofollow&quot;&gt;Here&#039;s more information on the problem&lt;/a&gt;.

I&#039;m always wary of methods that return a &lt;code&gt;struct&lt;/code&gt;, like &lt;code&gt;NSRange&lt;/code&gt;, because they are ill behaved if something is &lt;code&gt;nil&lt;/code&gt;.</description>
		<content:encoded><![CDATA[<p>Unfortunately, if <code>string</code> is <code>nil</code>, then <code>-rangeOfString:</code> is going to give you an undefined value, especially on iPhone. You probably want to check that <code> string != nil</code> before calling <code>-rangeOfString:</code>.  <a href="http://vgable.com/blog/2009/04/19/beware-rangeof-nsstring-operations/" rel="nofollow">Here&#8217;s more information on the problem</a>.</p>
<p>I&#8217;m always wary of methods that return a <code>struct</code>, like <code>NSRange</code>, because they are ill behaved if something is <code>nil</code>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
