iOS9 supports indexing the content in apps to support spotlight search, which is a very innovative feature. It should be mentioned that these indexes are stored in the local device and will not be synchronized to iCloud. If you change the device, they will be gone. The effect is this: Create search-enabled content The class that supports searchable content is CSSearchableItem. The attributes that can be displayed are title, description text, and thumbnail. It is recommended to set an expiration date (expirationDate) for each item. First, create an object CSSearchableItemAttributeSet that represents a configuration display content
AttributeSet also supports phone numbers and geographic coordinates. There will be corresponding actions on the right, and there will be an arrow if it supports navigation. (Because my app does not need this function, I have not tried it myself)
Creating a CSSearchableItem uniqueIdentifier is equivalent to the id of this data. domainIdentifier indicates the related domain. Apple also provides a set of APIs to modify and delete these indexes. domainIdentifier can be used as a parameter, for example, all indexes under a domain can be deleted.
Add CSSearchableItem to the system
Tips Most apps may also need to be compatible with iOS8. Here is how to determine whether it is compatible with iOS 8 in Swift. If you want to use iOS9 API in a method, use the following to judge (Xcode7 will also remind you).
If you want to indicate that a method you wrote is only available on iOS 9, add the following keywords to the method header to indicate that it is only available on iOS 9.
I will paste my project code directly. Processing of users selecting and opening the app after searching Just add this callback in the app delegate.
The method under OC is this
This can be used to get the identifier set when creating the CSSearchableItem
Then you can use this identifier to retrieve the corresponding data and process it. Reference Links:
|
<<: Nanjing Hearthstone CEO Zhu Wei: Mobile game development can also be "unconventional"
Editor’s Note: Please do not conduct any tests or...
Recently, Lenovo Group Chairman and CEO Yang Yuan...
Author: Hao Yun Reviewer: Wang Kang, Director of ...
“Let me check Weibo again, in case there is any e...
November 12th is the 111th birthday of Hua Luogen...
Even if you have 50,000, 500,000, or 5 million, i...
May 17, 2023 is the 19th "World Hypertension...
Recently, at the Haigeng Dam next to Dianchi Lake...
The 4 key points of growth hacking: Providing hig...
Expert of this article: Jiang Chenkun, School of ...
When talking about dinosaurs, many people think o...
Background of Kuaishou Jewelry Industry Jewelry p...
In the thousand-yuan motherboard market, which is...
There was no trap in the world, but when more peo...
Old project replay automatic hanging platform, si...