Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-23-2009, 08:20 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
Default Get the type of the iPhone programmatically?

Hello guys,

Is it possible to know the type of the iPhone( iPhone, iPhone 3G, iPhone 3GS) from the code somehow?

Cheers,
__________________
-Hosam
hosam is offline   Reply With Quote
Old 06-23-2009, 10:57 PM   #2 (permalink)
ftm
FasterThanMonkeys.com
iPhone Dev SDK Supporter
 
Join Date: Mar 2009
Location: Southern California
Posts: 521
Send a message via AIM to ftm
Default

Look at the UIDevice object.

[[UIDevice currentDevice] model];
[[UIDevice currentDevice] name];
[[UIDevice currentDevice] systemName];
[[UIDevice currentDevice] systemVersion];

Lots of good info about the device you are running on can be found through this object.
__________________


Website: http://fasterthanmonkeys.com

iScore Baseball Scorekeeper Top baseball scorekeeping app for iPhone
Bug Squash Reached #1 kids game in 15+ countries including USA, now with OpenFeint
Jam Packed! Fun puzzle game for all ages
Jam Packed Christmas Holiday puzzle game!
iScore Basketball Scorekeeper Best basketball scorekeeping application
ftm is offline   Reply With Quote
Old 06-24-2009, 08:46 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
Default

Quote:
Originally Posted by ftm View Post
Look at the UIDevice object.

[[UIDevice currentDevice] model];
[[UIDevice currentDevice] name];
[[UIDevice currentDevice] systemName];
[[UIDevice currentDevice] systemVersion];

Lots of good info about the device you are running on can be found through this object.
Looks like there is no way to know the type of the device your running on. The max to know is whether its an iPhone or an iPod touch which is the value returned from the model property

There is no work around this somehow?

Many thanks
__________________
-Hosam
hosam is offline   Reply With Quote
Old 06-24-2009, 09:02 PM   #4 (permalink)
Lost in a sea of code
 
BostonMerlin's Avatar
 
Join Date: Apr 2008
Location: Boston
Posts: 388
Default

i'm working on a class to give me exactly what you're looking for. not sure when i'll get around to finishing it but i'm basically taking information from UIDevice and then testing individual hardware functions to determine the device... such as if video or compass capabilities exist then it must be a 3gs, if gps exists it must be at least a 3g or 3gs, if camera exists it must be an iphone, 3g or 3gs etc..

Good luck.. i'll post my class when done.. but in the mean time something like this shouldnt take you long to build.. and in the process you'll learn some things along the way.

John
__________________
----------------------------------------------------------------------
I love being a dad, flying airplanes and writing code.
----------------------------------------------------------------------
Follow me on Twitter: @BostonMerlin
Feed your brain on Twitter: @iPhoneDev101
----------------------------------------------------------------------
iPhone Apps:
BostonMerlin is offline   Reply With Quote
Old 06-24-2009, 09:13 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
Default

Quote:
Originally Posted by BostonMerlin View Post
i'm working on a class to give me exactly what you're looking for. not sure when i'll get around to finishing it but i'm basically taking information from UIDevice and then testing individual hardware functions to determine the device... such as if video or compass capabilities exist then it must be a 3gs, if gps exists it must be at least a 3g or 3gs, if camera exists it must be an iphone, 3g or 3gs etc..

Good luck.. i'll post my class when done.. but in the mean time something like this shouldnt take you long to build.. and in the process you'll learn some things along the way.

John
sounds like fun. I guess I will do that, needs some digging though to know what's different between each model.

Cheers
__________________
-Hosam
hosam is offline   Reply With Quote
Old 06-24-2009, 09:36 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 176
Default

You can do something like this:
Code:
	struct utsname u;
	uname(&u);
	NSString *nameString = [NSString stringWithFormat:@"%s", u.machine];
nameString will be either iPod1,1 iPod1,2 and iPhone1,1 iPhone1,2 iPhone1,3

You will also need to import this header:
Code:
#import <sys/utsname.h>
__________________
FingerTest: Fun game where you put your fingers to the ultimate test! [AppStore] - $0.99
Penguins!: Addictive game. [AppStore] - $1.99
MTracker: Easy to use money tracker. [AppStore] - $0.99
iBubblePop: Try to pop as many bubbles as you can![AppStore] - $1.99

If you would like me to work on a project for you, contact me at the following email address.
madpike05@aol.com
ipodtouchmaster05 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 277
21 members and 256 guests
ashish_pandita, bucko, funkyspider, husoft, iMoan, iSdkDev, JJJohan, Jompe71, Leopard, Mac393, mauri, mavrick3, myPhone, navneetgahlot, PTKiPhone2010, SimonHodgkiss, Slum, Son of a Beach, tiderip, tomylee1, ZunePod
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,233
Threads: 39,011
Posts: 171,108
Top Poster: smasher (2,570)
Welcome to our newest member, PTKiPhone2010
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0