title and displayName properties on CSSearchableItemAttributeSet

335 views Asked by At

I'm building an app that uses CSSearchableItemAttributeSet with NSUserActivity in order to add items to the Spotlight Search index. The items I'm indexing are emojis, which consist of the emoji character itself, a description, and an image that shows the emoji.

I've noticed there is a title property on CSSearchableItemAttributeSet and there's also one called displayName. What's the difference between these, where do they appear to the end user, does title appear unless displayName is provided, or how do these two interact and present themselves to the user? I'm trying to figure out which I need to use in my scenario or if I need both.

The documentation for displayName reads: A localized string that contains the name of the item, suitable to display in the user interface.

The documentation for title reads: An item title might be the title of a document or MP3 file or the subject of an email message.

1

There are 1 answers

1
PGDev On BEST ANSWER

If the CSSearchableItemAttributeSet displayName property is set, it takes precedence over title property in search results.

If both displayName and title property of CSSearchableItemAttributeSet are set, then the search results will show the displayName property. Also, the item is searchable through both title and displayName.