<?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: Determine Device Type &#8211; 3G or 3GS / iPod First or Second Generation</title>
	<atom:link href="http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html/feed" rel="self" type="application/rss+xml" />
	<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.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: ThomasW</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-64079</link>
		<dc:creator>ThomasW</dc:creator>
		<pubDate>Wed, 07 Dec 2011 10:50:41 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-64079</guid>
		<description>iPhone 4S identifies itself as &quot;iPhone4,1&quot;.
on Lion the simulator identifies itself as &quot;x86_64&quot;.</description>
		<content:encoded><![CDATA[<p>iPhone 4S identifies itself as &#8220;iPhone4,1&#8243;.<br />
on Lion the simulator identifies itself as &#8220;x86_64&#8243;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roi</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-52260</link>
		<dc:creator>Roi</dc:creator>
		<pubDate>Thu, 09 Jun 2011 15:06:10 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-52260</guid>
		<description>According to www.everymac.com iPad2,2 represents an iPad 2 (Wi-Fi/GSM/A-GPS) for example of AT&amp;T and iPad2,3 represents an iPad 2 (Wi-Fi/CDMA/A-GPS) for example of Verizon</description>
		<content:encoded><![CDATA[<p>According to <a href="http://www.everymac.com" rel="nofollow">http://www.everymac.com</a> iPad2,2 represents an iPad 2 (Wi-Fi/GSM/A-GPS) for example of AT&amp;T and iPad2,3 represents an iPad 2 (Wi-Fi/CDMA/A-GPS) for example of Verizon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bsd2</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-52259</link>
		<dc:creator>bsd2</dc:creator>
		<pubDate>Thu, 09 Jun 2011 14:56:31 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-52259</guid>
		<description>Here&#039;s some code you can use with everything laid out nicely with defines... this is UIDevice+machine.h
UIDevice+machine.m (remains unchanged..)
-----------------------------------------------
#define IPHONE_SIM	@&quot;i386&quot;			//480x320 res

#define IPHONE_BASE@&quot;iPhone1,1&quot;	//480x320 res
#define IPHONE_3G	@&quot;iPhone1,2&quot;	//480x320 res
#define IPHONE_3GS@&quot;iPhone2,1&quot;	//480x320 res
#define IPHONE_4G	@&quot;iPhone3,1&quot;	//960x640 res (retina display)

#define IPOD_GEN1	@&quot;iPod1,1&quot;		//480x320 res
#define IPOD_GEN2	@&quot;iPod2,1&quot;		//480x320 res
#define IPOD_GEN3	@&quot;iPod3,1&quot;		//480x320 res
#define IPOD_GEN4	@&quot;iPod4,1&quot;		//960x640 res (retina display)

#define IPAD1		@&quot;iPad1,1&quot;		//1024x768 res (hd)
#define IPAD2		@&quot;iPad2,3&quot;		//1024x768 res (hd)

@interface UIDevice(machine)
- (NSString *)machine;
@end

------------------------ (CheckScreen.h)----------------------
@interface CheckScreen : NSObject

{
	@public
	BOOL isSmallScreen;
	BOOL isRetinaScreen;
	CheckScreen *checkScreen;
}

-(BOOL)isSmallScreen;
-(BOOL)isRetinaScreen;

@end

------------------------ (CheckScreen.m)----------------------
#import &quot;CheckScreen.h&quot;
#import &quot;UIDevice+machine.h&quot;

@implementation CheckScreen

- (BOOL)isSmallScreen
{
	
	if ([[[UIDevice currentDevice] machine] isEqualToString: IPHONE_SIM]	&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_BASE]	&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_3G]		&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_3GS]	&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN1]		&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN2]		&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN3]		&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_4G]		&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN4]
		)
		
		{
			isSmallScreen = 1;
		}
	
	else
		{
			isSmallScreen = 0;	
		}
		
	return isSmallScreen;
	
}

- (BOOL)isRetinaScreen
{

	if ([[[UIDevice currentDevice] machine] isEqualToString: IPHONE_4G]	&#124;&#124;
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN4])

		{
			isRetinaScreen = 1;
		}

	else
		{
			isRetinaScreen = 0;	
		}

	return isRetinaScreen;

	}

@end

----------------------------------------------(then ask the device to do something anywhere...)

		CheckScreen *checkScreen = [[CheckScreen alloc] autorelease];
		
		if([checkScreen isSmallScreen])	{
			do something....
		}
		
		else{
			do something....
		}</description>
		<content:encoded><![CDATA[<p>Here&#8217;s some code you can use with everything laid out nicely with defines&#8230; this is UIDevice+machine.h<br />
UIDevice+machine.m (remains unchanged..)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
#define IPHONE_SIM	@&#8221;i386&#8243;			//480&#215;320 res</p>
<p>#define IPHONE_BASE@&#8221;iPhone1,1&#8243;	//480&#215;320 res<br />
#define IPHONE_3G	@&#8221;iPhone1,2&#8243;	//480&#215;320 res<br />
#define IPHONE_3GS@&#8221;iPhone2,1&#8243;	//480&#215;320 res<br />
#define IPHONE_4G	@&#8221;iPhone3,1&#8243;	//960&#215;640 res (retina display)</p>
<p>#define IPOD_GEN1	@&#8221;iPod1,1&#8243;		//480&#215;320 res<br />
#define IPOD_GEN2	@&#8221;iPod2,1&#8243;		//480&#215;320 res<br />
#define IPOD_GEN3	@&#8221;iPod3,1&#8243;		//480&#215;320 res<br />
#define IPOD_GEN4	@&#8221;iPod4,1&#8243;		//960&#215;640 res (retina display)</p>
<p>#define IPAD1		@&#8221;iPad1,1&#8243;		//1024&#215;768 res (hd)<br />
#define IPAD2		@&#8221;iPad2,3&#8243;		//1024&#215;768 res (hd)</p>
<p>@interface UIDevice(machine)<br />
- (NSString *)machine;<br />
@end</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; (CheckScreen.h)&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
@interface CheckScreen : NSObject</p>
<p>{<br />
	@public<br />
	BOOL isSmallScreen;<br />
	BOOL isRetinaScreen;<br />
	CheckScreen *checkScreen;<br />
}</p>
<p>-(BOOL)isSmallScreen;<br />
-(BOOL)isRetinaScreen;</p>
<p>@end</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; (CheckScreen.m)&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
#import &#8220;CheckScreen.h&#8221;<br />
#import &#8220;UIDevice+machine.h&#8221;</p>
<p>@implementation CheckScreen</p>
<p>- (BOOL)isSmallScreen<br />
{</p>
<p>	if ([[[UIDevice currentDevice] machine] isEqualToString: IPHONE_SIM]	||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_BASE]	||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_3G]		||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_3GS]	||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN1]		||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN2]		||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN3]		||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPHONE_4G]		||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN4]<br />
		)</p>
<p>		{<br />
			isSmallScreen = 1;<br />
		}</p>
<p>	else<br />
		{<br />
			isSmallScreen = 0;<br />
		}</p>
<p>	return isSmallScreen;</p>
<p>}</p>
<p>- (BOOL)isRetinaScreen<br />
{</p>
<p>	if ([[[UIDevice currentDevice] machine] isEqualToString: IPHONE_4G]	||<br />
		[[[UIDevice currentDevice] machine] isEqualToString: IPOD_GEN4])</p>
<p>		{<br />
			isRetinaScreen = 1;<br />
		}</p>
<p>	else<br />
		{<br />
			isRetinaScreen = 0;<br />
		}</p>
<p>	return isRetinaScreen;</p>
<p>	}</p>
<p>@end</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-(then ask the device to do something anywhere&#8230;)</p>
<p>		CheckScreen *checkScreen = [[CheckScreen alloc] autorelease];</p>
<p>		if([checkScreen isSmallScreen])	{<br />
			do something&#8230;.<br />
		}</p>
<p>		else{<br />
			do something&#8230;.<br />
		}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bsd2</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-52254</link>
		<dc:creator>bsd2</dc:creator>
		<pubDate>Thu, 09 Jun 2011 14:36:51 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-52254</guid>
		<description>Thanks Ivan.

Ipad1 = &quot;iPad1,1&quot;
Ipad2 = &quot;iPad2,3&quot;

But is every iPad2 the same hardware code?

Thanks,
Jeremy</description>
		<content:encoded><![CDATA[<p>Thanks Ivan.</p>
<p>Ipad1 = &#8220;iPad1,1&#8243;<br />
Ipad2 = &#8220;iPad2,3&#8243;</p>
<p>But is every iPad2 the same hardware code?</p>
<p>Thanks,<br />
Jeremy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Vučica</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-52234</link>
		<dc:creator>Ivan Vučica</dc:creator>
		<pubDate>Thu, 09 Jun 2011 11:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-52234</guid>
		<description>Hey, bsd2,

I&#039;d love to know the device name for iPad and iPad2. If you&#039;re using the above code, you could use:

NSLog(&quot;%@&quot;, [UIDevice machine]);

to find out the device name, as returned by sysctl &quot;hw.machine&quot;. Please tell us what the device name is on both iPads!</description>
		<content:encoded><![CDATA[<p>Hey, bsd2,</p>
<p>I&#8217;d love to know the device name for iPad and iPad2. If you&#8217;re using the above code, you could use:</p>
<p>NSLog(&#8220;%@&#8221;, [UIDevice machine]);</p>
<p>to find out the device name, as returned by sysctl &#8220;hw.machine&#8221;. Please tell us what the device name is on both iPads!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bsd2</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-52162</link>
		<dc:creator>bsd2</dc:creator>
		<pubDate>Wed, 08 Jun 2011 20:06:43 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-52162</guid>
		<description>This code works great, but iPad2 is not recognized properly with  iPad2,1 or iPad1,2....  I ended up checking for the small screen and retina display and just using an else to handle the iPad cases, which is working great.  Just wanted to let you guys know, and I&#039;d be curious to know what the actual param is to get the iPad2 for future reference, never know when you&#039;ll need it!</description>
		<content:encoded><![CDATA[<p>This code works great, but iPad2 is not recognized properly with  iPad2,1 or iPad1,2&#8230;.  I ended up checking for the small screen and retina display and just using an else to handle the iPad cases, which is working great.  Just wanted to let you guys know, and I&#8217;d be curious to know what the actual param is to get the iPad2 for future reference, never know when you&#8217;ll need it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mr.Black</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-42916</link>
		<dc:creator>Mr.Black</dc:creator>
		<pubDate>Sun, 06 Mar 2011 04:18:52 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-42916</guid>
		<description>Great Thanks!!</description>
		<content:encoded><![CDATA[<p>Great Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Vučica</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-41601</link>
		<dc:creator>Ivan Vučica</dc:creator>
		<pubDate>Tue, 22 Feb 2011 11:48:21 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-41601</guid>
		<description>Instead of shortening the code (and breaking in case someone does decide hw.machine should be something longer than 128), I suggest that it may be a good idea to even add a check for failure of sysctlbyname() to the original code. In case Apple removes &quot;hw.machine&quot; on a future iOS or on a future device, the app would cease to function on that device.</description>
		<content:encoded><![CDATA[<p>Instead of shortening the code (and breaking in case someone does decide hw.machine should be something longer than 128), I suggest that it may be a good idea to even add a check for failure of sysctlbyname() to the original code. In case Apple removes &#8220;hw.machine&#8221; on a future iOS or on a future device, the app would cease to function on that device.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roi</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-40309</link>
		<dc:creator>Roi</dc:creator>
		<pubDate>Thu, 10 Feb 2011 10:33:55 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-40309</guid>
		<description>That&#039;s a great code. Thanks a lot!!!
By the way the iPod Touch 4 is identified as iPod4,1</description>
		<content:encoded><![CDATA[<p>That&#8217;s a great code. Thanks a lot!!!<br />
By the way the iPod Touch 4 is identified as iPod4,1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Byron</title>
		<link>http://MobileDeveloperTips.com/device/determine-if-iphone-is-3g-or-3gs-determine-if-ipod-is-first-or-second-generation.html#comment-36222</link>
		<dc:creator>Byron</dc:creator>
		<pubDate>Fri, 31 Dec 2010 19:27:51 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=3453#comment-36222</guid>
		<description>this is a little bit nit picky, but I&#039;d recommend creating the temp string on the stack instead of on the heap with malloc. I doubt hw.machine will ever return a string larger than 128 or so.


this method would then be fewer lines of code:

&lt;pre lang=&quot;objc&quot;&gt;
size_t size;
char name[128];
sysctlbyname(&quot;hw.machine&quot;, name, &amp;size, NULL, 0);
return [[NSString stringWithUTF8String:name] autorelease];
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>this is a little bit nit picky, but I&#8217;d recommend creating the temp string on the stack instead of on the heap with malloc. I doubt hw.machine will ever return a string larger than 128 or so.</p>
<p>this method would then be fewer lines of code:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">size_t</span> size;
<span style="color: #a61390;">char</span> name<span style="color: #002200;">&#91;</span><span style="color: #2400d9;">128</span><span style="color: #002200;">&#93;</span>;
sysctlbyname<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;hw.machine&quot;</span>, name, <span style="color: #002200;">&amp;</span>amp;size, <span style="color: #a61390;">NULL</span>, <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithUTF8String<span style="color: #002200;">:</span>name<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
	</item>
</channel>
</rss>

