2011-12-08 18 views
7

Olası Çoğalt:
Determine device (iPhone, iPod Touch) with iPhone SDKiPhone/iPod Aygıtı modeli (3G, 3GS, 4,4S) kodu nasıl bulunur?

Ben 3G, 3GS, 4,4S, iPodtouch (Farklı Nesiller) gibi güncel cihaz modeli adını almak için çalıştık. Ama şu ana kadar kesin bir sonuç alamıyorum. Cihaz modelini bulmama yardım edebilir misiniz? Burada cihaz modelini aldığım kodumu ekledim.

UIDevice *device = [UIDevice currentDevice]; 
NSString *deviceVersion = [device systemVersion];//Return 4.0.1 and 5.0.1 
NSString *deviceName = [device systemName];//Return iPhone, iPod Touch 

Cihaz modeli 3G, 3GS, 4,4S, iPod Touch, iPad'i nasıl edinebilirim? Şimdiden teşekkürler.

+3

zaten büyük bir cevabı olan bir post yoktur. [Buraya Brian Robbins cevabı kontrol edin.] [1] [1]: http://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-iphone-sdk – gurooj

cevap

13
#import <sys/utsname.h> 

NSString* 
machineName() 
{ 
    struct utsname systemInfo; 
    uname(&systemInfo); 

    return [NSString stringWithCString:systemInfo.machine 
           encoding:NSUTF8StringEncoding]; 
} 

sonucu olmalıdır:

@"i386"  on the simulator 
@"iPod1,1" on iPod Touch 
@"iPod2,1" on iPod Touch Second Generation 
@"iPod3,1" on iPod Touch Third Generation 
@"iPod4,1" on iPod Touch Fourth Generation 
@"iPhone1,1" on iPhone 
@"iPhone1,2" on iPhone 3G 
@"iPhone2,1" on iPhone 3GS 
@"iPad1,1" on iPad 
@"iPad2,1" on iPad 2 
@"iPhone3,1" on iPhone 4 
@"iPhone4,1" on iPhone 4S 
+0

Teşekkür ederim BayNithin. Kodunuz beklediğim kadar mükemmel çalışıyor. Çok teşekkürler. – Gopinath

+0

Yeni modeller için güncelleme. iPhone 5, iPhone 5 (beyaz) ve iPhone 6,2 iPhone 5s (altın) kendi cihazlarından. – Joey

2

Girhub'da bir kütüphane var. Bu bağlantıyı bakınız:

https://github.com/erica/uidevice-extension

+0

Bu yöntemler özel API kullanır ve büyük ihtimalle uygulamanızı reddeder. – WrightsCS

+2

@WrightsCS Bunlar, uygulama mağazası için uygun olmayan ve açıkça görülebilecek olanlara açıkça ayrılır. –

+0

Teşekkür ederim Mr.WrightsCS ve Mr.Anthony Blake. Değerli yardımlarınız için teşekkürler. – Gopinath