[Swift] Copy the character string to the clipboard

Thing you want to do

Copy the string from the iOS app to the clipboard. I think that it is a requirement that is sometimes required when developing an application.

Implementation method

It's very easy to implement. You can do it in one line. You don't even need to import the library.

copy2clipboard.swift


UIPasteboard.general.string = "The string you want to copy"

Operation check environment

Xcode: 11.7 iOS: 13.7 Swift version: Swift5

that's all

Recommended Posts

[Swift] Copy the character string to the clipboard
Change only one character from the String type string to uppercase
Convert iso-2022-jp character string to utf-8
When the character string passed to C ++ by JNA is garbled
[Rails] How to omit the display of the character string of the link_to method
Shorten the UUID to base64 in Swift.
[Swift] How to implement the countdown function
Deletes after the specified character from the character string
[Ruby] I want to output only the odd-numbered characters in the character string
I want to find out what character the character string appears from the left
Convert from C String pointer to Swift String type
[Swift 5] Processing to close the keyboard on UITableView
[Android] How to convert a character string to resourceId
[Delete the first letter of the character string] Ruby
[Swift] How to implement the LINE login function
Convert a string to a character-by-character array with swift
[swift5] How to implement the Twitter share function
How to add sound in the app (swift)
[Swift] How to link the app with Firebase
[Java] How to easily get the longest character string of ArrayList using stream
[Swift] How to implement the fade-in / out function
[Note] About the introduction to Swift practice Chapter 11
I want to output the character number from the left where an arbitrary character string appears.
# 1_JAVA I want to get the index number by specifying one character in the character string.
[Java] How to cut out a character string character by character
[Java] How to erase a specific character from a character string
[Swift] Use UserDefaults to save data in the app
[Kotlin] Convert ZonedDateTime to String by specifying the format
[Swift] How to get the document ID of Firebase
URL to String conversion
I want to find out if the specified character string is supported by the target character code
How to transition from the [Swift5] app to the iPhone settings screen
Import the date string automatically converted to Excel with java.time.LocalDate
[Swift] I tried to implement the function of the vending machine
[Java] How to convert a character string from String type to byte type
Set the date and time from the character string with POI
[Java] How to use substring to cut out a character string
Add a shadow to the Swift Button (and also the circle)
[Introduction to Java] Handling of character strings (String class, StringBuilder class)
[Swift] When you want to know if the number of characters in a String matches a certain number ...
About the method to convert a character string to an integer / decimal number (cast data) in Java
Code to specify the image name as a character string and paste it into ImageView (android)
[Java beginner] Conversion from character string to numerical value-What is the parseInt method of the Integer class? ~