An open API service indexing awesome lists of open source software.

https://github.com/hyun99999/uipasteboardtutorial-ios

πŸ“Ž ν΄λ¦½λ³΄λ“œλ‘œ λ³΅μ‚¬ν•˜κΈ° λŒ€μž‘μ „
https://github.com/hyun99999/uipasteboardtutorial-ios

ios uipasteboard

Last synced: 2 months ago
JSON representation

πŸ“Ž ν΄λ¦½λ³΄λ“œλ‘œ λ³΅μ‚¬ν•˜κΈ° λŒ€μž‘μ „

Awesome Lists containing this project

README

        

# UIPasteboardTutorial-iOS
πŸ“Ž ν΄λ¦½λ³΄λ“œλ‘œ λ³΅μ‚¬ν•˜κΈ° λŒ€μž‘μ „

**λ‚΄μš©**
- λ²„νŠΌμ„ ν†΅ν•΄μ„œ νŠΉμ • λ¬Έμžμ—΄μ„ μ†μ‰½κ²Œ ν΄λ¦½λ³΄λ“œμ— λ³΅μ‚¬ν•˜κΈ°.

# μ‹œμž‘ μ „

λ¨Όμ € `UIPateboard` 에 λŒ€ν•΄μ„œ κ°œλ°œμžλ¬Έμ„œλ₯Ό 톡해 μ•Œμ•„λ³΄μž.

## πŸ–‡ [UIPasteboard](https://developer.apple.com/documentation/uikit/uipasteboard)

μ‚¬μš©μžκ°€ μ•± λ‚΄μ˜ ν•œ μœ„μΉ˜μ—μ„œ λ‹€λ₯Έ μœ„μΉ˜λ‘œ 데이터λ₯Ό κ³΅μœ ν•˜λŠ” 것을 λ•λŠ” 객체.

**Overview**

λ‹€λ₯Έ μ•±κ³Ό 데이터λ₯Ό κ³΅μœ ν•˜λ €λ©΄ μ‹œμŠ€ν…œ μ „μ²΄μ˜ genaral pasteboard λ₯Ό μ‚¬μš©ν•΄λΌ.

같은 team ID λ₯Ό κ°€μ§€λŠ” λ‹€λ₯Έ μ•±μœΌλ‘œ 데이터λ₯Ό κ³΅μœ ν•˜λ €λ©΄ pasteboards 의 이름을 μ‚¬μš©ν•΄λΌ.

일반적으둜 μ•±μ˜ κ°μ²΄λŠ” μœ μ €κ°€ μΈν„°νŽ˜μ΄μŠ€μ˜ 선택항λͺ©μ— λŒ€ν•œ 볡사, μž˜λΌλ‚΄κΈ°, 볡제 μž‘μ—…μ„ μš”μ²­ν•  λ•Œ 데이터λ₯Ό μ“΄λ‹€. 그런 λ‹€μŒ κ°™κ±°λ‚˜ λ‹€λ₯Έ μ•±μ˜ λ‹€λ₯Έ 객체가 pasteboard μ—μ„œ 데이터λ₯Ό 읽고 μƒˆ μœ„μΉ˜μ—μ„œ μ œκ³΅ν•œλ‹€. 이것은 일반적으둜 λΆ™μ—¬λ„£κΈ° μž‘μ—…μ„ μš”μ²­ν•  λ•Œ λ°œμƒν•œλ‹€.

**Note**

iOS 14 λΆ€ν„° μ‹œμŠ€ν…œμ€ λ‹€λ₯Έμ•±μ˜ pasteboard 컨텐츠λ₯Ό κ°€μ Έμ˜€λ©΄ μ‚¬μš©μžμ—κ²Œ μ•Œλ¦°λ‹€.

### The General Pasteboard and Named Pasteboards

μ‹œμŠ€ν…œ μ „μ²΄μ˜ general pasteboard λŠ” [general](https://developer.apple.com/documentation/uikit/uipasteboard/1622106-general) μƒμˆ˜λ‘œ μ‹λ³„λœλ‹€. λͺ¨λ“  μœ ν˜•μ˜ 데이터λ₯Ό 이λ₯Ό ν†΅ν•΄μ„œ paste board λ₯Ό μ–»μ–΄μ„œ μ‚¬μš©κ°€λŠ₯ν•˜λ‹€.

[init(name:create:)](https://developer.apple.com/documentation/uikit/uipasteboard/1622074-init) 및 [withUniqueName()](https://developer.apple.com/documentation/uikit/uipasteboard/1622087-withuniquename) 클래슀 λ©”μ„œλ“œλ‘œ pasteboards λ₯Ό μƒμ„±ν•˜μ—¬ λ™μΌν•œ Team ID λ₯Ό κ°€μ§„ λ‹€λ₯Έ μ•±μœΌλ‘œ 데이터λ₯Ό κ³΅μœ ν•  수 μžˆλ‹€.

### Using Pasteboards

UIPasteboard ν΄λž˜μŠ€λŠ” κ°œλ³„μ μΈ pasteboard items λ₯Ό 읽고 μ“°λŠ” 방법과 μ—¬λŸ¬κ°€μ§€ pasteboard items λ₯Ό ν•œλ²ˆμ— 읽고 μ“°λŠ” 방법을 μ œκ³΅ν•œλ‹€. μžμ„Έν•œ λ‚΄μš©μ€ 이 λ¬Έμ„œ ν•˜λ‹¨μ˜ `Getting and Setting pasteboard Items` λ₯Ό 참쑰해라.

pasteboard 에 μ“Έ λ°μ΄ν„°λŠ” λ‹€μŒ 두 ν˜•μ‹μ€‘ ν•˜λ‚˜μΌ 수 μžˆλ‹€.

- 데이터가 NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage, or NSURL κ³Ό 같은 객체둜 ν‘œν˜„λ  수 μžˆλŠ” 경우 κ°’μœΌλ‘œ ν‘œμ‹œλ  수 μžˆλ‹€. [setValue(_:forPasteboardType:)](https://developer.apple.com/documentation/uikit/uipasteboard/1622079-setvalue) 와 같은 λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•΄μ„œ pastboard 에 μ“΄λ‹€.
- λ§Œμ•½ 데이터가 binary 인 경우, [setData(_:forPasteboardType:)](https://developer.apple.com/documentation/uikit/uipasteboard/1622075-setdata) λ©”μ„œλ“œλ₯Ό μ‚¬μš©ν•˜μ—¬ pastboard 에 μ“΄λ‹€.

UIPasteboard ν΄λž˜μŠ€λŠ” 단일 ν˜Ήμ€ μ—¬λŸ¬ pasteboard items 에 λ¬Έμžμ—΄, 이미지, URLs, colors 을 읽고 μ“°κΈ°μœ„ν•œ νŽΈλ¦¬ν•œ λ©”μ„œλ“œλ₯Ό μ œκ³΅ν•œλ‹€. (λ¬Έμ„œ ν•˜λ‹¨μ˜ `Getting and Setting Pasteboard Items of Standard Data Types` μ°Έμ‘°)

λ‹€μŒμ„ μ‚¬μš©ν•΄μ„œ UIPasteboard 에 데이터λ₯Ό 기둝해보겠닀. κ½€ κ°„λ‹¨ν•˜λ‹€!

# μ‹œμž‘ν•˜κΈ°

- λ²„νŠΌμ— 이벀트λ₯Ό λΆ€μ—¬ν•΄μ„œ ν΄λ¦½λ³΄λ“œλ‘œ μ†μ‰½κ²Œ λ³΅μ‚¬ν•΄λ³΄κΈ°λ‘œ ν–ˆλ‹€.
- 데이터 κ³΅μœ ν•˜κΈ° μœ„ν•΄μ„œ general pasteboard λ₯Ό μ–»μ–΄μ„œ μ‚¬μš©ν•΄λ³΄μž

### πŸ–‡ Main λ·°

### πŸ–‡ UIPasteboard 이용

- MainViewController

```swift
import UIKit

class ViewController: UIViewController {

@IBOutlet weak var idText: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
}

// βœ… λ²„νŠΌ ν΄λ¦­μ‹œ idText 의 ν…μŠ€νŠΈ pastebaord 에 볡사.
@IBAction func pasteText(_ sender: Any) {
UIPasteboard.general.string = idText.text
}
}
```

### πŸ–‡ μ™„μ„±