2009-07-08 13 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

+0

@Tim:あなたは絶対に正しいです。私はそれを考えなかった。しかし、私はチュートリアルを提案していませんでした。私は単に私の情報源と詳細情報源を提供していました。 –

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

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ユーザー、これを使用

+0

ありがとうございます。 Swift 3の場合: UIDevice.current.name –

関連する問題