2009-07-08 144 views

回答

151

類:

作爲一個例子:[[UIDevice currentDevice] name];

的的UIDevice是提供有關該iPhone或iPod 觸控裝置 信息的類。

由 提供的部分信息UIDevice是靜態的,例如設備名稱或系統版本號爲 。

來源:http://servin.com/iphone/uidevice/iPhone-UIDevice.html

官方文檔:Apple Developer Documentation >UIDevice Class Reference

+2

請注意:該鏈接的教程雖然很實用,但針對OS 2.2,並使用了3.0中不推薦使用的一些方法。 – Tim 2009-07-08 19:49:45

+0

@Tim:你是對的。我沒有想到這一點。雖然,我並不是在建議教程;我只是提供我的信息來源和更多信息的來源。 – 2009-07-08 19:58:09

175

除了上面的回答,這是實際代碼:

[[UIDevice currentDevice] name];

2

爲了獲得iPhone的設備名稱編程

UIDevice *deviceInfo = [UIDevice currentDevice]; 

NSLog(@「Device name: %@」, deviceInfo.name); 

//設備名稱:我的iPod

55

斯威夫特:

UIDevice.currentDevice().name 

斯威夫特3:

UIDevice.current.name 
+1

必須有導入UIKit – DrWhat 2016-06-09 09:37:15

5

這裏的UIDevice

+ (UIDevice *)currentDevice; 

@property(nonatomic,readonly,strong) NSString *name;    // e.g. "My iPhone" 
@property(nonatomic,readonly,strong) NSString *model;    // e.g. @"iPhone", @"iPod touch" 
@property(nonatomic,readonly,strong) NSString *localizedModel; // localized version of model 
@property(nonatomic,readonly,strong) NSString *systemName;  // e.g. @"iOS" 
@property(nonatomic,readonly,strong) NSString *systemVersion; 
4

的階級結構xamarin用戶,使用這個

UIKit.UIDevice.CurrentDevice.Name