Notice
Recent Posts
Recent Comments
Link
관리 메뉴

김종권의 iOS 앱 개발 알아가기

[iOS - swift] UniformTypeIdentifiers 개념 (#UTType, data transfer) 본문

iOS 응용 (swift)

[iOS - swift] UniformTypeIdentifiers 개념 (#UTType, data transfer)

jake-kim 2024. 2. 26. 01:55

UniformTypeIdentifiers 개념

https://developer.apple.com/documentation/uniformtypeidentifiers

  • 파일 형식 및 데이터 유형을 식별하기 위한 표준을 의미
  • 다양한곳에서 파일 형식을 식별하고 처리가 필요한데 일종의 규격이므로 개발자들이 파일 형식을 관리하고 다루는 데 있어서 유용한 표준 

사용처

  • 앱에서 특정 데이터 포멧을 사용할 때, info.plist에 등록하는 형태로도 사용

  • 애플의 파일 시스템 object들을 식별할 수 있는 단위로 사용

https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers

  • OS단에서 파일등의 데이터들을 주고받을때 확장자 구분이 필요할 경우가 있는데, 이럴 때 UTType.으로 접근
    • UTType의 static 프로퍼티로 선언되어 있고, id값을 얻어오려면 아래처럼 접근
    • id값은 일반적으로 public prefix를 붙인 형태
    • share sheet에서 UTType을 활용하는 예제는 이 포스팅 글 참고
print(UTType.text.identifier) // public.text
  • UTTypeReference을 활용하면 data를 로드하고, 보내고 받을 수 있는 객체 형식도 표현이 가능
    • 이 객체로 만들고 id값, tags 등 추가 정보를 저장하는 형태

* 참고

- https://developer.apple.com/documentation/uniformtypeidentifiers/uttype

- https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers

- https://developer.apple.com/documentation/uniformtypeidentifiers

Comments