Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.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, 09:20 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 26
Posts: 243
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, 11:57 PM   #2 (permalink)
ftm
FasterThanMonkeys.com
 
Join Date: Mar 2009
Location: Southern California
Posts: 523
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, 09:46 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 26
Posts: 243
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, 10:02 PM   #4 (permalink)
Lost in a sea of code
 
BostonMerlin's Avatar
 
Join Date: Apr 2008
Location: Boston
Posts: 399
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, 10:13 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Germany
Age: 26
Posts: 243
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, 10:36 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 180
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
Old 01-13-2011, 07:33 PM   #7 (permalink)
Try This At Home
 
Gweetle's Avatar
 
Join Date: Nov 2010
Location: Planet Earth
Posts: 194
Default

Quote:
Originally Posted by ipodtouchmaster05 View Post
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>
On the iPhone 4, it's returning "iPhone3,1"
Does anyone know the values for the newest iPod touch 4, or iPad?
__________________
Gweetle is offline   Reply With Quote
Old 01-14-2011, 03:05 AM   #8 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Amsterdam, The Netherlands
Posts: 782
Default

iPhone = iPhone1,1
iPhone 3G = iPhone1,2
iPhone 3GS = iPhone2,1
iPhone 4 = iPhone3,1
CDMA iPhone = iPhone3,2

iPad Wifi = iPad1,1
iPad 3G = iPad1,2 (not sure about this one)

iPod Touch 1G = iPod1,1
iPod Touch 2G = iPod2,1
iPod Touch 3G = iPod3,1
iPod Touch 4G = iPod4,1

I've not checked it but this.
__________________
If my answer helped you, you might want to help me.
Make a donation via PayPal.

Last edited by TUX2K; 01-14-2011 at 03:17 AM.
TUX2K is offline   Reply With Quote
Old 04-14-2011, 04:56 AM   #9 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
Default I was wondering ...

Quote:
Originally Posted by ipodtouchmaster05 View Post
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>
... if Apple allows this function "uname". I had such a problem before and I needed to change that.

I need to get the Device information (version) too, but is it possible to get information if the device has a retina display?
How does iOS "decide", if it should take a picture called "picture.png" or "picture_name@2x.png"?

Best regards
Nic
Nic_Tesla432 is offline   Reply With Quote
Old 04-14-2011, 05:34 AM   #10 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
Default Hi again

I came across the post iPhone @2x Graphics, scale, and iPad.

It uses the C-function sysctlbyname()

BR
Nic
Nic_Tesla432 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



» Advertisements
» Online Users: 423
10 members and 413 guests
AppleSteve, chiataytuday, DaveDee, Domele, HowEver, ilmman, Jameswhitfield, johnRambo, LEARN2MAKE, shiv@globussoft.com
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,854
Threads: 88,915
Posts: 379,298
Top Poster: BrianSlick (7,072)
Welcome to our newest member, Jameswhitfield
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:42 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0