iOS has a class called UIPasteboard which lets you access the last value that a user has copied or cut to the clipboard (or pasteboard).
The class has a singleton which lets you access a string like so:
1 2 |
// latest copy/cut string operation NSString *latest = [UIPasteboard generalPasteboard].string; |
This will work fine when any kind of text is involved. Copy/Cut/Paste is also available for images from the Photos app though, and you can access the latest UIImage like this:
1 2 |
// latest image UIImage *latestImage = [UIPasteboard generalPasteboard].image; |
Note that those two values are mutually exclusive: if you’ve copied an image, then the text string will be nil, and when you’ve copied text then the image value will be nil.
The UIPasteboard class is very versatile and lets you do all kinds of things – check out the Class Reference for more information:
私はこのブログのレイアウトを崇拝します。それはどのように作られたのか?それは本当に良いです!
。私は単にあなたにつまずいブログと私がしたことを言いたかった本当にあなたのブログの記事を閲覧楽しみました。 はるかいずれの場合では、私はあなたのRSSフィードを購読することだろうと私はあなたが一度書い願っ本当にすぐ!