Created
January 2, 2013 20:10
-
-
Save codeswimmer/4437535 to your computer and use it in GitHub Desktop.
iOS: Simple Usage Of UIPasteBoard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Basically, UIPasteBoard allows us to share data to other application. Below is an example of UIpasteBoard usage. | |
COPY | |
UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard]; | |
appPasteBoard.persistent = YES; | |
[appPasteBoard setString:@"STRING TO COPY"]; | |
PASTE | |
UIPasteboard *appPasteBoard = [UIPasteboard generalPasteboard]; | |
yourTextField.text = [appPasteBoard string]; | |
You can also specify a pasteboard name or identifier to copy and paste data. See example code below. | |
Copy and Paste Image files. | |
COPY | |
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyPaste" create:YES]; | |
appPasteBoard.persistent = YES; | |
NSData *data = UIImagePNGRepresentation([UIImage imageNamed:@"COPIED.jpg"]); | |
[appPasteBoard setData:data forPasteboardType:@"com.yourCompany.yourApp.yourType"]; | |
PASTE | |
UIPasteboard *appPasteBoard = [UIPasteboard pasteboardWithName:@"CopyPaste" create:YES]; | |
NSData *data = [appPasteBoard dataForPasteboardType:@"com.yourCompany.yourApp.yourType"]; | |
imageView.image = [UIImage imageWithData:data]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to create UIpasteboard and copy and paste and please code is where exucte in so, please whole program to answer