nevan king
nevan king

Reputation: 113747

How is the Find pasteboard used?

I'm reading through the docs for UIPasteboard, and it says that there are two main types of pasteboard, the "General Pasteboard", used for system-wide copy and paste, and the "Find Pasteboard" (UIPasteboardNameFind). From the docs:

The Find pasteboard, which is used in search operations, holds the most recent string value in the search bar

If I enter text into the search bar in Safari, it doesn't get placed into the Find Pasteboard for another app. I'm wondering how the Find Pasteboard works, and what it's used for. I'm imagining that it's scope is inside an app or family of apps, but what's the difference from just using the UISearchbar's text property?

Here's the code I'm using to inspect it:

UIPasteboard *findPasteboard = [UIPasteboard pasteboardWithName:UIPasteboardNameFind create:NO];
NSLog(@"Find Pasteboard: %@", findPasteboard);
NSLog(@"Find Pasteboard items: %@", [findPasteboard items]);

Upvotes: 2

Views: 789

Answers (1)

MCCCS
MCCCS

Reputation: 1022

iOS 10 deprecates every clipboard other than the general one; here is an answer for macOS:

The Find Pasteboard keeps the most recent find string entered in the findbar. (But not the address bar!) It's designed to complement the universal Command + F shortcut.

Here is an example scenario:

  • User opens TextEdit's findbar and enters a string
  • TextEdit copies the string to the Find Pasteboard
  • User opens Safari's findbar
  • The findbar opens with the string pasted from the Find Pasteboard

For developers, these are the implementation guidelines:

  • On findbar string change, the new string should be copied to the Find Pasteboard
  • The findbar string must be kept in sync with the Find Pasteboard (either through time-loop checks "Every N seconds" like Safari or when the app becomes active as TextEdit, Firefox, Chrome do)

Upvotes: 1

Related Questions