iPhone의 장치 이름을 가져오는 방법
여는 경우Settings -> General -> About
화면 맨 위에 밥의 아이폰이라고 나옵니다.프로그래밍 방식으로 그 이름을 어떻게 얻습니까?
클래스에서:
빠른 버전:
UIDevice.current.name
목표-C 버전:
[[UIDevice currentDevice] name];
UID 장치는 iPhone 또는 iPod Touch 장치에 대한 정보를 제공하는 클래스입니다.
UID 장치에서 제공하는 일부 정보(예: 장치 이름 또는 시스템 버전)는 정적입니다.
출처: http://servin.com/iphone/uidevice/iPhone-UIDevice.html
공식 문서: Apple 개발자 설명서 >UIDevice
클래스 참조
위의 답변 외에도 실제 코드는 다음과 같습니다.
[[UIDevice currentDevice] name];
기억:import UIKit
스위프트:
UIDevice.currentDevice().name
스위프트 3, 4, 5:
UIDevice.current.name
UID 장치의 클래스 구조입니다.
+ (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;
아래 코드에 사용된 swift 4.0 이상의 경우:
let udid = UIDevice.current.identifierForVendor?.uuidString
let name = UIDevice.current.name
let version = UIDevice.current.systemVersion
let modelName = UIDevice.current.model
let osName = UIDevice.current.systemName
let localized = UIDevice.current.localizedModel
print(udid ?? "") // ABCDEF01-0123-ABCD-0123-ABCDEF012345
print(name) // Name's iPhone
print(version) // 14.5
print(modelName) // iPhone
print(osName) // iOS
print(localized) // iPhone
불행히도 iOS 16부터는 특별한 자격이 필요합니다.https://developer.apple.com/contact/request/user-assigned-device-name/ 에서 요청할 수 있습니다.
사마린 사용자의 경우 다음을 사용합니다.
UIKit.UIDevice.CurrentDevice.Name
Swift 4+ 버전의 경우 아래 코드를 사용하십시오.
UIDevice.current.name
iPhone의 장치 이름을 프로그래밍 방식으로 가져오려면 다음과 같이 하십시오.
UIDevice *deviceInfo = [UIDevice currentDevice];
NSLog(@"Device name: %@", deviceInfo.name);
// Device name: my iPod
장치 이름은 지금 즉시 사용할 수 없습니다. 특별한 자격이 필요합니다.
사용 권한 : com.apple.developer.device-information.user-assigned-device-name
문서: https://developer.apple.com/forums/thread/708275
공식: https://developer.apple.com/documentation/uikit/uidevice/1620015-name
Unity에서 C# 사용:
SystemInfo.deviceName;
iOS 16 기준name
그것은 사용할 수 없고 불행하게도 저는 대안을 찾을 수 없었습니다.부터UIKit.UIDevice
:
open var name: String { get } // Synonym for model. Prior to iOS 16, user-assigned device name (e.g. @"My iPhone").
언급URL : https://stackoverflow.com/questions/1100127/how-do-you-get-an-iphones-device-name
'code' 카테고리의 다른 글
파일을 복사하는 포스트 tsc 빌드 작업을 추가하는 방법은 무엇입니까? (0) | 2023.07.07 |
---|---|
SQL Server 사용자 매핑 오류 15023 (0) | 2023.07.07 |
jQuery로 머리글과 바닥글 사이를 스크롤할 때 사이드바를 고정시키는 방법은 무엇입니까? (0) | 2023.07.02 |
Angular - *ngIf 대 템플릿의 단순 함수 호출 (0) | 2023.07.02 |
TypeScript의 클래스에 오리 타이핑이 허용되는 이유 (0) | 2023.07.02 |