<?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 and NSInteger</title>
	<atom:link href="http://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Mon, 08 Mar 2010 17:46:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: John Muchow</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#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://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#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://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#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://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#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>
	<item>
		<title>By: John</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#comment-178</link>
		<dc:creator>John</dc:creator>
		<pubDate>Thu, 22 Jan 2009 03:06:34 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-178</guid>
		<description>Chris,

It depends on how you stored the NSNumber to the plist. For example, if you stored the NSNumber object into an NSArray, you might have something like this:

NSInteger someInt = [[tmpArray objectAtIndex:0] integerValue];

In this case I am assuming the NSNumber object was stored in a plist which was an array of objects. I then convert the value at index 0 to an integer (using the method integerValue).

John</description>
		<content:encoded><![CDATA[<p>Chris,</p>
<p>It depends on how you stored the NSNumber to the plist. For example, if you stored the NSNumber object into an NSArray, you might have something like this:</p>
<p>NSInteger someInt = [[tmpArray objectAtIndex:0] integerValue];</p>
<p>In this case I am assuming the NSNumber object was stored in a plist which was an array of objects. I then convert the value at index 0 to an integer (using the method integerValue).</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://iPhoneDeveloperTips.com/cocoa/nsnumber-and-nsinteger.html/comment-page-1#comment-177</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 22 Jan 2009 02:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1404#comment-177</guid>
		<description>Hi there.  I found this article useful, but have a further question.  I converted an int into an NSNumber and was able to successfully save it to my preferences.plist for my application.  I am a bit befuddled when it comes to reading the NSNumber back out and converting it into an int again.  Yes, I am fairly new to objective C, and am not sure how to cast the NSNumber back into an int.</description>
		<content:encoded><![CDATA[<p>Hi there.  I found this article useful, but have a further question.  I converted an int into an NSNumber and was able to successfully save it to my preferences.plist for my application.  I am a bit befuddled when it comes to reading the NSNumber back out and converting it into an int again.  Yes, I am fairly new to objective C, and am not sure how to cast the NSNumber back into an int.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
