How can I read data from the general pasteboard for all classes?

363 views Asked by At

At the moment I'm using readObjectsForClasses: to retrieve a list of objects from the general pasteboard in cocoa, which works whenever I want to only retrieve objects of a certain class e.g. NSString or NSImage etc.

However, I would like to be able to read every single object in it without having to make an array of all of their classes, such that the array returned would contain every single item in the pasteboard.

Is this possible?

1

There are 1 answers

0
Merlevede On

Have you tried using the types method of the NSPasteboard object? I haven't tried it but the documentation says:

Return Value
An array of NSString objects containing the union of the types of data declared for all the pasteboard items on the receiver. The returned types are listed in the order they were declared.

With this method you can probably query the pasteboard types, even if you won't be able to read them.