💡 Documents, data, and pasteboard란?
목차
- Documents
- Initializing a document object
- Accessing document attributes
- Writing document data
- Reading document data
- Accessing document files asynchronously
- Reverting a document
- Disabling and enabling editing
- Tracking changes and autosaving
- Supporting user activities
- Resolving conflicts and handling errors
- Constants
- Notifications
- Data management
- Pasteboard
1. Document
- UI Document란?
- 앱의 이산 부분을 관리하는 추상적인 기본 클래스이다. *이산은 분리되거나 분할된 것을 의미한다. ex)방은 집 안의 분리된 공간인 것 처럼
- UI MAnaged Document란?
2. Data management
- 앱에서 데이터 개체에 대한 영구 참조를 제공하기 위한 인터페이스를 정의하는 메서드 집합이다.
3. Pasteboard
-
UIPasteControl (class)
- 게시판의 내용들을 활용하여 앱에 배치할 수 있는 버튼을 의미
-
UIPasteControl. Configuration (class)
- 붙여넣기 대상의 색상, 모서리 스타일, 아이콘 및 텍스트를 결정하는 개체
-
UIPasteControl.DisplayMode (enum)
- 아이콘, 텍스트 레이블 혹은 둘 모두를 구성하는지 여부를 결정하는 옵션
- enum이란? enum은 'Emumerations'의 줄임말로써 번역하자면 열거형 입니다. 이름에서 부터 알려주듯이 값을 요케저케 열거해가지구 내가 원하는 값을 뾰로록 뽑아낼 수 있게 해주는 간편한 아이지용 :) !

-
UIPasteboaed (class)
- 사용자가 앱 내의 한 장소에서 다른 장소로, 그리고 앱에서 다른 앱으로 데이터를 공유할 수 있도록 도와주는 개체이다.
-
UIPasteConfiguration (class)
- 붙여넣기, 끌어서 놓기 작업을 위해 특정 데이터 형식을 허용하는 기능을 선언하기 위해 개체가 구현하는 인터페이스이다.
-
UIPasteConfigyrationSupporting (protocol)
1.UI Document / Initializing a document object
- init(fileURL: URL)
- 매개변수 URL로, 문서가 기록될 위치를 식별하는 파일 URL이다.
- 개체를 만들 수 없는 경우 결과값 0을 나타낸다.
💡 `init(fileURL url: [URL](https://developer.apple.com/documentation/foundation/url))` → 다음과 같이 선언한다.
- fileURL
- 샌드박스에서 문서의 위치를 식별할 때 쓰인다. 여기에는 파일 형식이 결절되는 파일 확장자 또한 포함이 된다.
- sandbox란 무엇인가?
- App Sandbox란 커널 수준에서 강제 적용되는 맥 OS의 접근제어 기술이다. App이 손상될 경우, 시스템과 사용자 데이터의 손상을 막기위해 설계된 것으로 App Store에서 유통되는 App들은 모두 App Sandbox를 적용시켜야 한다.
- App Sandbox는 개발자가 앱과 시스템이 어떻게 상호작용하게 할 것인지 권한을 부여하는 기능을 한다. 이는 사용자가 드래그 앤 드롭등의 친숙한 인터렉션을 통해 투명하게 앱에 추가 권한을 부여할 수 있도록 한다.
- 아무 생각 없이 접근 요청만 코딩할 줄 알았지, 접근 제어 기술, SandBox 이라는 명칭으로 쓰이고 있다는 것도 처음 안 사실이네요.
[iOS] iOS SandBox 란?
기본적으로 UIKIt는 파일 이름 구성요소에서 값을 가져온다. 따라서 호출 전에 해당 속성을 설정해야 한다.
Accessing document attributes.
var fileURL: URL
💡 `var localizedName: [String](https://developer.apple.com/documentation/swift/string) { get }`
var localizedName: String
💡 var fileType: `[String](https://developer.apple.com/documentation/swift/string)`
? { get }
var fileModificationDaye: Date?
💡 var fileModificationDate: `[Date](https://developer.apple.com/documentation/foundation/date)`
? { get set }
var documentState: UIDocument.state
💡 var documentState: `[UIDocument](https://developer.apple.com/documentation/uikit/uidocument)`
.`[State](https://developer.apple.com/documentation/uikit/uidocument/state)`
{ get }
var progress: Progress?
💡 var progress: `[Progress](https://developer.apple.com/documentation/foundation/progress)`
? { get }
Writing document data.
- close(completionHandler:)
💡 func close(completionHandler: ((`[Bool](https://developer.apple.com/documentation/swift/bool)`
) -> `[Void](https://developer.apple.com/documentation/swift/void)`
)? = nil)
해당 함수 호출을 통해 안전하고 비동기적으로 문서를 저장하는 호출을 할 수 있다.
기본적으로는 해당 함수가 아닌, autosave(completionHandler)메서드를 호출한다.
💡 func contents(forType typeName: `[String](https://developer.apple.com/documentation/swift/string)`
) throws -> Any
저장할 문서데이터를 반환할 때 사용한다.
- save(to:for:completionHandler:)
💡 func save(
to url:
[URL](https://developer.apple.com/documentation/foundation/url)
,
for saveOperation:
[UIDocument](https://developer.apple.com/documentation/uikit/uidocument)
.
[SaveOperation](https://developer.apple.com/documentation/uikit/uidocument/saveoperation)
,
completionHandler: ((
[Bool](https://developer.apple.com/documentation/swift/bool)
) ->
[Void](https://developer.apple.com/documentation/swift/void)
)? = nil
)
응용 프로그램 샌드박스의 지정된 위치에 문서 데이터를 저장합니다.
- writeContents(_:andAttributes:safelyTo:for:)
💡 func writeContents(
_ contents: Any,
andAttributes additionalFileAttributes: [
[AnyHashable](https://developer.apple.com/documentation/swift/anyhashable)
: Any]? = nil,
safelyTo url:
[URL](https://developer.apple.com/documentation/foundation/url)
,
for saveOperation:
[UIDocument](https://developer.apple.com/documentation/uikit/uidocument)
.
[SaveOperation](https://developer.apple.com/documentation/uikit/uidocument/saveoperation)
) throws
문서 데이터는 애플리케이션 샌드박스에서 지정된 위치에 안전하게 작성됩니다.
2. UIManagedDocument
UIManaged Document는 UID 문서의 구체적인 하위 클래스이며, 관리되는 문서를 초기화할 때 문서 위치의 URL을 지정합니다.
3. UIPasteboard
사용자가 앱 내의 한 장소에서 다른 장소로, 그리고 앱에서 다른 앱으로 데이터를 공유할 수 있도록 도와주는 개체입니다.
클립보드 개념이라고 생각하면 될 듯.
