<?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: NSNumber versus NSInteger</title>
	<atom:link href="http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/feed" rel="self" type="application/rss+xml" />
	<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html</link>
	<description>iOS and Objective-C Tips, Tricks and Tutorials.</description>
	<lastBuildDate>Sat, 19 May 2012 05:15:17 -0500</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Ted</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-17477</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Fri, 18 Jun 2010 18:47:40 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-17477</guid>
		<description>Thanks guys.  Ted S</description>
		<content:encoded><![CDATA[<p>Thanks guys.  Ted S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Furlani</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-17465</link>
		<dc:creator>Stephen Furlani</dc:creator>
		<pubDate>Fri, 18 Jun 2010 15:33:20 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-17465</guid>
		<description>@Ted,

You can use C-type arrays for primitives and (id).

id bob[10];

compiles just fine.

NSArray provides all the *memory management* associated with handling objects in Obj-C so that

NSArray *joe = [NSArray arrayWithContentsOfURL: myURL];

creates all the objects and 

[joe release];

removes them all from memory.  Otherwise, you&#039;d have to:

for (int i = 0; i &lt; 10; i++) {
    [bob[i] release];
}

Hope that helps!

-S!</description>
		<content:encoded><![CDATA[<p>@Ted,</p>
<p>You can use C-type arrays for primitives and (id).</p>
<p>id bob[10];</p>
<p>compiles just fine.</p>
<p>NSArray provides all the *memory management* associated with handling objects in Obj-C so that</p>
<p>NSArray *joe = [NSArray arrayWithContentsOfURL: myURL];</p>
<p>creates all the objects and </p>
<p>[joe release];</p>
<p>removes them all from memory.  Otherwise, you&#8217;d have to:</p>
<p>for (int i = 0; i &lt; 10; i++) {<br />
    [bob[i] release];<br />
}</p>
<p>Hope that helps!</p>
<p>-S!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalle</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-16211</link>
		<dc:creator>Kalle</dc:creator>
		<pubDate>Mon, 31 May 2010 09:11:27 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-16211</guid>
		<description>Author: a-ha! Thanks!

hhamm: yes, it&#039;s slow. If speed is what you need, NSNumber is out of the question.

Ted: because NSArray auto-retains and auto-releases and does a lot of things which require that whatever you put in there responds to certain protocols (namely those dictated in NSObject).

-Kalle.</description>
		<content:encoded><![CDATA[<p>Author: a-ha! Thanks!</p>
<p>hhamm: yes, it&#8217;s slow. If speed is what you need, NSNumber is out of the question.</p>
<p>Ted: because NSArray auto-retains and auto-releases and does a lot of things which require that whatever you put in there responds to certain protocols (namely those dictated in NSObject).</p>
<p>-Kalle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-15857</link>
		<dc:creator>Ted</dc:creator>
		<pubDate>Wed, 26 May 2010 02:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-15857</guid>
		<description>One thing I didn&#039;t see anyone ask here is &#039;Why?  Why is it necessary to use objects in NSArrays?&#039;  In C++ we can make an array of any type, primitive, class etc without &#039;wrapping&#039; it in another layer of code.  Why is it different in Obj-C?

Anyone know why?

Thanks</description>
		<content:encoded><![CDATA[<p>One thing I didn&#8217;t see anyone ask here is &#8216;Why?  Why is it necessary to use objects in NSArrays?&#8217;  In C++ we can make an array of any type, primitive, class etc without &#8216;wrapping&#8217; it in another layer of code.  Why is it different in Obj-C?</p>
<p>Anyone know why?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srikanth rongali</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-15189</link>
		<dc:creator>srikanth rongali</dc:creator>
		<pubDate>Fri, 14 May 2010 05:23:11 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-15189</guid>
		<description>Hi,
I  am confused of using int  or NSInteger. But, thanks for suggesting a better one  NSNumber. 
Can we access the NSNumber objects in other classes like NSString objects ? 
ActuallyI need to access the values declared in classB from classA. By using int, float types it is not working. Which is better for this case NSInteger or NSNumber. 
Thank you,
Please post me answer to mail id if not a problem to you.
srikanth_rongali@yahoo.co.in</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I  am confused of using int  or NSInteger. But, thanks for suggesting a better one  NSNumber.<br />
Can we access the NSNumber objects in other classes like NSString objects ?<br />
ActuallyI need to access the values declared in classB from classA. By using int, float types it is not working. Which is better for this case NSInteger or NSNumber.<br />
Thank you,<br />
Please post me answer to mail id if not a problem to you.<br />
<a href="mailto:srikanth_rongali@yahoo.co.in">srikanth_rongali@yahoo.co.in</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hhamm</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-11709</link>
		<dc:creator>hhamm</dc:creator>
		<pubDate>Tue, 23 Mar 2010 12:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-11709</guid>
		<description>My current solution for such math is :
value = [NSNumber numberWithInt:[value intValue] + 10];

but this seems to be slow, memory intensive and ugly... 
how to calc something more complex with that ? 

like : 

value = value * t + (1-t) * ( sin( value * M_PI) )

value = [NSNumber numberWithFloat:[value floatValue] * t + (1-t) *  (sin ( [value floatValue] * M_PI) )];

*phooo* that stinks!</description>
		<content:encoded><![CDATA[<p>My current solution for such math is :<br />
value = [NSNumber numberWithInt:[value intValue] + 10];</p>
<p>but this seems to be slow, memory intensive and ugly&#8230;<br />
how to calc something more complex with that ? </p>
<p>like : </p>
<p>value = value * t + (1-t) * ( sin( value * M_PI) )</p>
<p>value = [NSNumber numberWithFloat:[value floatValue] * t + (1-t) *  (sin ( [value floatValue] * M_PI) )];</p>
<p>*phooo* that stinks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-8240</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Tue, 29 Dec 2009 15:01:07 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-8240</guid>
		<description>Justin,

I don&#039;t think it&#039;s possible to write a method as you have shown passing in a &quot;number&quot; as NSNumber is an object and NSInteger is standard C data type (not an object). You could have a method where you pass in an object of type &quot;id&quot; the generic object type and then determine if the object is an NSNumber similar to this: 

&lt;pre lang=&quot;objc&quot;&gt;
-(void)reportDataType:(id) number
{
  if ([number isKindOfClass:[NSNumber class]])
    NSLog(@&quot;Is NSNumber&quot;);
  ...
}
&lt;/pre&gt;

I wrote about determining class types here: &lt;a href=&quot;http://iphonedevelopertips.com/user-interface/detect-taps-on-uitabbarcontroller-and-determining-class-type.html&quot; rel=&quot;nofollow&quot;&gt;Determining Class Types&lt;/a&gt;

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Justin,</p>
<p>I don&#8217;t think it&#8217;s possible to write a method as you have shown passing in a &#8220;number&#8221; as NSNumber is an object and NSInteger is standard C data type (not an object). You could have a method where you pass in an object of type &#8220;id&#8221; the generic object type and then determine if the object is an NSNumber similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>reportDataType<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span> number
<span style="color: #002200;">&#123;</span>
  <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>number isKindOfClass<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Is NSNumber&quot;</span><span style="color: #002200;">&#41;</span>;
  ...
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>I wrote about determining class types here: <a href="http://iphonedevelopertips.com/user-interface/detect-taps-on-uitabbarcontroller-and-determining-class-type.html" rel="nofollow">Determining Class Types</a></p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-8238</link>
		<dc:creator>Justin</dc:creator>
		<pubDate>Tue, 29 Dec 2009 13:41:41 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-8238</guid>
		<description>How do I check on receipt of a variable if it is NSInteger or NSNumber?

-(void)reportDataType:number{

     if(...) NSLog(@&quot;received NSInteger&quot;);
     if(...) NSLog(@&quot;received NSNumber&quot;);

}</description>
		<content:encoded><![CDATA[<p>How do I check on receipt of a variable if it is NSInteger or NSNumber?</p>
<p>-(void)reportDataType:number{</p>
<p>     if(&#8230;) NSLog(@&#8221;received NSInteger&#8221;);<br />
     if(&#8230;) NSLog(@&#8221;received NSNumber&#8221;);</p>
<p>}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-6413</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 09 Nov 2009 02:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-6413</guid>
		<description>Thanks for this post, cleared a (noob) problem I&#039;ve been having with my NSDictionary.</description>
		<content:encoded><![CDATA[<p>Thanks for this post, cleared a (noob) problem I&#8217;ve been having with my NSDictionary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://MobileDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html#comment-179</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 22 Jan 2009 05:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-179</guid>
		<description>That worked like a charm.  Thanks for the speedy answer!</description>
		<content:encoded><![CDATA[<p>That worked like a charm.  Thanks for the speedy answer!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

