在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:algolia/instantsearch-ios开源软件地址:https://github.com/algolia/instantsearch-ios开源编程语言:Swift 99.3%开源软件介绍:By Algolia. InstantSearch family: InstantSearch iOS | InstantSearch Android | React InstantSearch | InstantSearch.js | Angular InstantSearch | Vue InstantSearch. InstantSearch iOS is a framework providing components and helpers to help you build the best instant-search experience on iOS with Algolia. It is built on top of Algolia's Swift API Client library to provide you a high-level solution to quickly build various search interfaces. StructureInstantSearch iOS consists of three products
ExamplesYou can see InstantSearch iOS in action in the Examples project. It contains search components ans experiences built with InstantSearch and written in Swift. InstallationSwift Package ManagerThe Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. Since the release of Swift 5 and Xcode 11, SPM is compatible with the iOS, macOS and tvOS build systems for creating apps. To use SwiftPM, you should use Xcode 11 to open your project. Click If you're a framework author and use InstantSearch as a dependency, update your let package = Package(
// 7.18.0 ..< 8.0.0
dependencies: [
.package(url: "https://github.com/algolia/instantsearch-ios", from: "7.18.0")
],
// ...
) CocoaPodsCocoaPods is a dependency manager for Cocoa projects. To install InstantSearch, simply add the following line to your Podfile: pod 'InstantSearch', '~> 7.18'
# pod 'InstantSearch/Insights' for access to Insights library only
# pod 'InstantSearch/Core' for access business logic without UIKit components
# pod 'InstantSearch/SwiftUI' for access to SwiftUI components Then, run the following command: $ pod update CarthageCarthage is a simple, decentralized dependency manager for Cocoa.
github "algolia/instantsearch-ios" ~> 7.18
carthage update
./Carthage/Checkouts/instant-search-ios/carthage-prebuild
carthage build
If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage. DocumentationYou can start with the Getting Started Guide. Learn more about instantSearch iOS in the dedicated documentation website. Basic UsageIn your import InstantSearch
struct Item: Codable {
let name: String
}
class SearchResultsViewController: UITableViewController, HitsController {
var hitsSource: HitsInteractor<Item>?
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
hitsSource?.numberOfHits() ?? 0
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = hitsSource?.hit(atIndex: indexPath.row)?.name
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let _ = hitsSource?.hit(atIndex: indexPath.row) {
// Handle hit selection
}
}
}
class ViewController: UIViewController {
lazy var searchController = UISearchController(searchResultsController: hitsViewController)
let hitsViewController = SearchResultsViewController()
let searcher = HitsSearcher(appID: "latency",
apiKey: "1f6fd3a6fb973cb08419fe7d288fa4db",
indexName: "bestbuy")
lazy var searchConnector = SearchConnector<Item>(searcher: searcher,
searchController: searchController,
hitsInteractor: .init(),
hitsController: hitsViewController)
override func viewDidLoad() {
super.viewDidLoad()
searchConnector.connect()
searcher.search()
setupUI()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
searchController.isActive = true
}
func setupUI() {
view.backgroundColor = .white
navigationItem.searchController = searchController
searchController.hidesNavigationBarDuringPresentation = false
searchController.showsSearchResultsController = true
searchController.automaticallyShowsCancelButton = false
}
} You can now build and run your application to see the basic search experience in action. You should see that the results are changing on each key stroke. To get a more meaningful search experience, please follow the Getting Started Guide. If you build a SwiftUI application, please check out the Getting Started with SwiftUI guide If you only require business logic modules in your project and use TelemetryInstantSearch iOS collects data points at runtime. This helps the InstantSearch team improve and prioritize future development. Here's an exhaustive list of the collected data:
InstantSearch doesn't collect any sensitive or personal data. However, you can still opt out of the telemetry collection with the following code: InstantSearchTelemetry.shared.isEnabled = false Getting Help
Getting involved
LicenseInstantSearch iOS is Apache 2.0 licensed. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论