Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get string from nspasteboard

maybe it's been a long night but I am not able to understand how to check the clipboard for strings

I have been reading the NSPasteboard documentation..

could some one help me out?

like image 534
BlockReader Avatar asked May 29 '11 11:05

BlockReader


1 Answers

you need to use the following method with stringForType with key NSPasteboardTypeString to read the string value from clipboard.

- (NSString *)stringForType:(NSString *)dataType .

NSPasteboard*  myPasteboard  = [NSPasteboard generalPasteboard];
NSString* myString = [myPasteboard  stringForType:NSPasteboardTypeString];

To do this for iOS with UIPasteBoard use the following code:

UIPasteboard *thePasteboard = [UIPasteboard generalPasteboard];
NSString *pasteboardString = thePasteboard.string;
NSLog(@"%@", pasteboardString);
like image 189
Jhaliya - Praveen Sharma Avatar answered Oct 17 '22 03:10

Jhaliya - Praveen Sharma