반응형
Swift에서 프로그래밍 방식으로 번들 식별자를 얻습니까?
Swift에서 번들 ID를 얻으려면 어떻게해야합니까?
Objective-C 버전 :
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
이 시도:
let bundleID = NSBundle.mainBundle().bundleIdentifier
Swift 3+ :
let bundleID = Bundle.main.bundleIdentifier
클래스와 메소드 이름이 단축되었다는 점을 제외하면 Swift에서도 거의 동일합니다.
let bundleIdentifier = Bundle.main.bundleIdentifier // return type is String?
프로그래밍 방식으로 얻으려는 경우 아래 코드 줄을 사용할 수 있습니다.
목표 -C :
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
스위프트 3.0 :
let bundleIdentifier = Bundle.main.bundleIdentifier
최신 신속한 업데이트 iOS 및 Mac 앱 모두에서 작동합니다.
자세한 내용은 여기를 확인하십시오.
참고 URL : https://stackoverflow.com/questions/25897086/obtain-bundle-identifier-programmatically-in-swift
반응형
'Program Club' 카테고리의 다른 글
| 표준 입력에서 읽기 위해 sed를 어떻게 얻습니까? (0) | 2020.10.14 |
|---|---|
| 원인 : java.security.UnrecoverableKeyException : 키를 복구 할 수 없습니다. (0) | 2020.10.13 |
| 서비스 패브릭에 대한 환경 별 런타임 구성 매개 변수를 어디에 설정하고 액세스합니까? (0) | 2020.10.13 |
| TensorFlow에서 일괄 정규화를 어떻게 사용할 수 있습니까? (0) | 2020.10.13 |
| C #에서 bool 읽기 / 쓰기 원 자성입니다. (0) | 2020.10.13 |