Find & Replace: All properties on UITextSearchOptions are readonly? How am I supposed to use it with UIFindSession?

I'm trying to figure out how I'm suppose to work with this API on UIFindSession:

- (void)performSearchWithQuery:(NSString *)query options:(nullable UITextSearchOptions *)options;

I want to provide a UITextSearchOptions object, but the properties are readonly so I'm not sure what purpose it serves exposing it in the public API?

@interface UITextSearchOptions : NSObject

/// See UITextSearchMatchMethod above.

@property (nonatomic, readonly) UITextSearchMatchMethod wordMatchMethod;



/// Comparison options to use when searching for strings.

@property (nonatomic, readonly) NSStringCompareOptions stringCompareOptions;

@end

So I can't simply invoke a search like this...which would've really been nice...

       UIFindSession *session = findInterfaction.activeFindSession;
   UITextSearchOptions *searchOptions = [[UITextSearchOptions alloc]init];
 searchOptions.stringCompareOptions = NSCaseInsensitiveSearch; //readonly can't...
  [session performSearchWithQuery:searchString options:searchOptions];

There is this API:


/// available in @c UITextSearchOptions, which can be either modified, augmented, or omitted.

@property (nonatomic, readwrite, copy, nullable) UIMenu *_Nullable (^optionsMenuProvider)(NSArray<UIMenuElement *> *defaultOptions);

So I can remove menu items that edit the UITextSearchOptions but how exactly do I "override" them for my needs?

UITextSearchOptions are meant to only reflect the options configured in the find panel UI, which is why its properties are read only. Additionally, performSearchWithQuery:options: is meant to only be called by the system, not manually like in the code listing you provided.

Can I ask what you're trying to do exactly? Are you trying to trigger a search automatically in response to something happening in your app's UI? If so, I would instead suggest using -[UIFindInteraction presentFindNavigator], and if you want to pre-configure the search text, you can use UIFindInteraction.searchText.

I was hoping for more control of the search in app. In my case I'm just using "Find" (not replace).

The issue is my app uses UISearchController in another area that has its own search preferences so ideally I'd like to be able to configure the UIFindInteraction to match the search experience I already have. I'm not sure if users will understand that the search bar in one area is app provided and the "Find" experience is system provided and they could potentially have different preferences. So ideally, I want to configure the UIFindInteraction to match my existing search experience in another view controller but it doesn't appear to be possible unless I implement UIFindSession subclass from scratch, in which case I get almost nothing for free.

Also the UIFindInteraction's delegate is readonly, which makes determining when the Find Session ends much more difficult. I'd like to know when the "Find Panel UI" is finished so I can call -becomeFirstResponder on another UIResponder so the user can invoke undo/redo actions on it.

Find &amp; Replace: All properties on UITextSearchOptions are readonly? How am I supposed to use it with UIFindSession?
 
 
Q