I am trying to get string from NSPasteboard in Xamarin.Mac, here is my code
NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard;
string text = "";
Then what method of pasteboard do I use to store the string into text?
I am trying to get string from NSPasteboard in Xamarin.Mac, here is my code
NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard;
string text = "";
Then what method of pasteboard do I use to store the string into text?
If you know you have string-based data on the pasteboard, you can use GetStringForType using the type of NSStringType.
Example:
string text = NSPasteboard.GeneralPasteboard.GetStringForType(NSPasteboard.NSStringType);
Returns a concatenation of the strings for the specified type from all the items in the receiver that contain the type.
Otherwise you can cycle through all the items on in the pasteboard using
PasteboardItems to return an array of NSPasteboardItem and review each item for the type that you are looking for.