To run the example project, clone the repo, and run pod install from the Example directory first.
Fetching view has a state machine called Fetching State :
enumFetchingState<A>{case fetching
case fetchedError(AppErrorProvider)case fetchedData(A)}Fetching view will display UIActivityIndicatorView for FetchingState<A>.fetching and error message for .fetchedError(Error) state.
#####Here is an screenshot from an example application using FetchingView
FetchingView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod'FetchingView'import UIKit
import FetchingView
classViewController:UIViewController{@IBOutlet weak vartableView:UITableView!varfetchingView:FetchingView<[User]>!func viewDidLoad(){
super.viewDidLoad()...self.fetchingView =FetchingView(listView: tableView, parentView:self.view)}func fetchResource(){self.fetchingView.fetchingState =.fetching
User.fetchResource{ result iniflet error = result.error {self.fetchingView.fetchingState =.fetchedError(error)}iflet users = result.value {self.fetchingView.fetchingState =.fetchedData(users)
//update dataSource and reloadData
}}}}func showHUD(){self.fetchingView.showHUD()
// task
self.fetchingView.hideHUD()}func showMessageHUD(){self.fetchingView.showHUD(title:nil, message:"Your request is submitted successfully.", delay:2.0)}NeilsUltimateLab, neilsultimatelab@icloud.com
FetchingView is available under the MIT license. See the LICENSE file for more info.
