iOSのクリップボードについて調べた(Swift)

# クリップボードを取得する
**[String](https://developer.apple.com/documentation/uikit/uipasteboard/1622092-string) [(Strings)](https://developer.apple.com/documentation/uikit/uipasteboard/1622091-strings)**
```Swift
// String
if let string = UIPasteboard.general.string {
   print(string)
}
// Strings
if let strings = UIPasteboard.general.strings {
   print(strings)
}
```
**[Image](https://developer.apple.com/documentation/uikit/uipasteboard/1622069-image) [(Images)](https://developer.apple.com/documentation/uikit/uipasteboard/1622086-images)**
```Swift
// Image
if let image = UIPasteboard.general.image {
   print(image)
}
// Images
if let images = UIPasteboard.general.images {
   print(images)
}
```
**[URL](https://developer.apple.com/documentation/uikit/uipasteboard/1622081-url) [(URLs)](https://developer.apple.com/documentation/uikit/uipasteboard/1622097-urls)**
```Swift
// URL
if let url = UIPasteboard.general.url {
   print(url)
}
// URLs
if let urls = UIPasteboard.general.urls {
   print(urls)
}
```
**[Color](https://developer.apple.com/documentation/uikit/uipasteboard/1622085-color) [(Colors)](https://developer.apple.com/documentation/uikit/uipasteboard/1622078-colors)**
```Swift
// Color
if let color = UIPasteboard.general.color {
   print(color)
}
// Colors
if let color = UIPasteboard.general.color {
   print(color)
}
```
# クリップボードに値を設定する
**[String](https://developer.apple.com/documentation/uikit/uipasteboard/1622092-string) [(Strings)](https://developer.apple.com/documentation/uikit/uipasteboard/1622091-strings)**
```Swift
// String
UIPasteboard.general.string = "クリップボード"
// Strings
UIPasteboard.general.strings = ["クリップ", "ボード"]
```
**[Image](https://developer.apple.com/documentation/uikit/uipasteboard/1622069-image) [(Images)](https://developer.apple.com/documentation/uikit/uipasteboard/1622086-images)**
```Swift
// Image
UIPasteboard.general.image = UIImage(named: "sample")
// Images
UIPasteboard.general.images = [UIImage(named: "sample1"), UIImage(named: "sample2")]
```
**[URL](https://developer.apple.com/documentation/uikit/uipasteboard/1622081-url) [(URLs)](https://developer.apple.com/documentation/uikit/uipasteboard/1622097-urls)**
```Swift
// URL
UIPasteboard.general.url = URL(string: "https://google.com・")
// URLs
UIPasteboard.general.urls = [URL(string: "https://google.com・"), URL(string: "https://www.apple.com/")]
```

**[Color](https://developer.apple.com/documentation/uikit/uipasteboard/1622085-color) [(Colors)](https://developer.apple.com/documentation/uikit/uipasteboard/1622078-colors)**
```Swift
// Color
UIPasteboard.general.color = UIColor.black
// Colors
UIPasteboard.general.colors = [UIColor.black, UIColor.white]
```

# クリップボードの値の判定
**クリップボードの値がStringかどうか**
```Swift
print(UIPasteboard.general.hasStrings)
```
**クリップボードの値がUIImageかどうか**
```Swift
print(UIPasteboard.general.hasImages)
```
**クリップボードの値がUIColorかどうか**
```Swift
print(UIPasteboard.general.hasColors)
```
**クリップボードの値がURLかどうか**
```Swift
print(UIPasteboard.general.hasURLs)
```

# その他(使えそうなのピックアップ)
**[クリップボードの個数](https://developer.apple.com/documentation/uikit/uipasteboard/1622076-numberofitems)**
```Swift
// EX) 
// UIPasteboard.general.string = "クリップボード" -> 1
// UIPasteboard.general.strings = ["クリップ", "ボード"] -> 2

print(UIPasteboard.general.numberOfItems)
```

**[クリップボードの名前](https://developer.apple.com/documentation/uikit/uipasteboard/1622083-name)**
```Swift
print(UIPasteboard.general.name.rawValue)
```

**[クリップボードの変更回数](https://developer.apple.com/documentation/uikit/uipasteboard/1622103-changecount)**
```Swift
print(UIPasteboard.general.changeCount)
```

**[クリップボードの値の型](https://developer.apple.com/documentation/uikit/uipasteboard/1622077-types)**
```Swift
// String -> ["public.utf8-plain-text"]
// Image -> ["com.apple.uikit.image", "public.png", "public.jpeg"]
// URL -> ["public.url", "public.utf8-plain-text"]
// Color -> ["com.apple.uikit.color"]


print(UIPasteboard.general.types)
```