 |
 |
|
 |
06-23-2009, 08:20 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
|
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
|
|
|
06-23-2009, 10:57 PM
|
#2 (permalink)
|
|
FasterThanMonkeys.com
iPhone Dev SDK Supporter
Join Date: Mar 2009
Location: Southern California
Posts: 521
|
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.
|
|
|
06-24-2009, 08:46 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
|
Quote:
Originally Posted by ftm
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
|
|
|
06-24-2009, 09:02 PM
|
#4 (permalink)
|
|
Lost in a sea of code
Join Date: Apr 2008
Location: Boston
Posts: 388
|
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:
|
|
|
06-24-2009, 09:13 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Germany
Age: 24
Posts: 209
|
Quote:
Originally Posted by BostonMerlin
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
|
|
|
06-24-2009, 09:36 PM
|
#6 (permalink)
|
|
Registered Member
Join Date: Sep 2008
Posts: 176
|
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
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» 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 |
|