diff --git a/Example/RMRPullToRefresh/ViewController.swift b/Example/RMRPullToRefresh/ViewController.swift index 1432c01..29f6c63 100644 --- a/Example/RMRPullToRefresh/ViewController.swift +++ b/Example/RMRPullToRefresh/ViewController.swift @@ -46,7 +46,7 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega func configurePullToRefresh() { - pullToRefresh = RMRPullToRefresh(scrollView: tableView, position: position()) { [weak self] _ in + pullToRefresh = RMRPullToRefresh(scrollView: tableView, position: position()) { [weak self] in DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(5.0 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: { if self?.result == .success { self?.loadMore() @@ -117,22 +117,24 @@ class ViewController: UIViewController, UITableViewDataSource, UITableViewDelega @IBAction func settings(_ sender: AnyObject) { - UIActionSheet(title: "Result type", delegate: self, cancelButtonTitle: nil, destructiveButtonTitle: nil, otherButtonTitles: ".Success", ".NoUpdates", ".Error").show(in: self.view) - } - - // MARK: - UIActionSheetDelegate - - func actionSheet(_ actionSheet: UIActionSheet, clickedButtonAt buttonIndex: Int) { - switch buttonIndex { - case 0: - self.result = .success - case 1: + let alertController = UIAlertController(title: "Result type", message: nil, preferredStyle: .actionSheet) + + let successAction = UIAlertAction(title: "Success", style: .default) { _ in self.result = .noUpdates - case 2: - self.result = .error - default: - break; } + alertController.addAction(successAction) + + let noUpdatesAction = UIAlertAction(title: "No updates", style: .default) { _ in + self.result = .noUpdates + } + alertController.addAction(noUpdatesAction) + + let errorAction = UIAlertAction(title: "Error", style: .default) { _ in + self.result = .error + } + alertController.addAction(errorAction) + + present(alertController, animated: true, completion: nil) } // MARK: - Test data diff --git a/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj b/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj index 677b94a..eab2cec 100644 --- a/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj +++ b/Example/RMRPullToRefreshExample.xcodeproj/project.pbxproj @@ -150,12 +150,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = "Merkulov Ilya"; TargetAttributes = { 89CB12331C9DA07B00048E46 = { CreatedOnToolsVersion = 7.2.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; }; }; @@ -289,13 +289,21 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -333,13 +341,21 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -358,6 +374,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -372,7 +389,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.RMRPullToRefresh; PRODUCT_NAME = RMRPullToRefreshExample; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -386,7 +403,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.redmadrobot.RMRPullToRefresh; PRODUCT_NAME = RMRPullToRefreshExample; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; };