Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Add @discardableResul to avoid warnings of unused variable
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMobileDeveloper committed Aug 11, 2017
1 parent a8767e6 commit a3509f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
B3B543EE1F062A9800408912 /* DianpingTableviewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B543121F062A9700408912 /* DianpingTableviewController.swift */; };
B3B543EF1F062A9800408912 /* ElasticHeaderTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B543131F062A9700408912 /* ElasticHeaderTableViewController.swift */; };
B3B543F01F062A9800408912 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B3B543141F062A9700408912 /* [email protected] */; };
B3B543F11F062A9800408912 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B3B543151F062A9700408912 /* Info.plist */; };
B3B5442E1F062A9800408912 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B543521F062A9700408912 /* MainViewController.swift */; };
B3B5442F1F062A9800408912 /* QQVideoRefreshHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B543531F062A9700408912 /* QQVideoRefreshHeader.swift */; };
B3B544301F062A9800408912 /* QQVideoTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3B543541F062A9700408912 /* QQVideoTableViewController.swift */; };
Expand Down Expand Up @@ -340,7 +339,6 @@
B3B543E01F062A9700408912 /* banner2.jpg in Resources */,
B3B544AB1F062A9800408912 /* [email protected] in Resources */,
B3B543F01F062A9800408912 /* [email protected] in Resources */,
B3B543F11F062A9800408912 /* Info.plist in Resources */,
B3B543DE1F062A9700408912 /* Assets.xcassets in Resources */,
B3B544331F062A9800408912 /* [email protected] in Resources */,
B3B544A61F062A9800408912 /* [email protected] in Resources */,
Expand Down
5 changes: 3 additions & 2 deletions Demo/Demo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ class MainViewController: UITableViewController {
models.append(section1)
models.append(section2)
models.append(section3)
let header = self.tableView.setUpHeaderRefresh { [weak self] in
self.tableView.setUpHeaderRefresh { [weak self] in
let delayTime = DispatchTime.now() + Double(Int64(2 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: delayTime) {
self?.tableView.endHeaderRefreshing(.success,delay:0.3)
}
}.SetUp { (header) in
header.setThemeColor(themeColor: UIColor.blue)
}
header.setThemeColor(themeColor: UIColor.blue)
self.tableView.tableFooterView = UIView(frame: CGRect.zero)
}

Expand Down
9 changes: 9 additions & 0 deletions Source/Classes/PullToRefresh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public protocol RefreshableLeftRight:class{
public protocol SetUp {}
public extension SetUp where Self: AnyObject {
//Add @noescape to make sure that closure is sync and can not be stored
@discardableResult
public func SetUp(_ closure: (Self) -> Void) -> Self {
closure(self)
return self
Expand All @@ -133,10 +134,12 @@ extension NSObject: SetUp {}

//Header
public extension UIScrollView{
@discardableResult
public func setUpHeaderRefresh(_ action:@escaping ()->())->DefaultRefreshHeader{
let header = DefaultRefreshHeader(frame:CGRect(x: 0,y: 0,width: self.frame.width,height: PullToRefreshKitConst.defaultHeaderHeight))
return setUpHeaderRefresh(header, action: action)
}
@discardableResult
public func setUpHeaderRefresh<T:UIView>(_ header:T,action:@escaping ()->())->T where T:RefreshableHeader{
let oldContain = self.viewWithTag(PullToRefreshKitConst.headerTag)
oldContain?.removeFromSuperview()
Expand Down Expand Up @@ -170,10 +173,12 @@ public extension UIScrollView{

//Footer
public extension UIScrollView{
@discardableResult
public func setUpFooterRefresh(_ action:@escaping ()->())->DefaultRefreshFooter{
let footer = DefaultRefreshFooter(frame: CGRect(x: 0,y: 0,width: self.frame.width,height: PullToRefreshKitConst.defaultFooterHeight))
return setUpFooterRefresh(footer, action: action)
}
@discardableResult
public func setUpFooterRefresh<T:UIView>(_ footer:T,action:@escaping ()->())->T where T:RefreshableFooter{
let oldContain = self.viewWithTag(PullToRefreshKitConst.footerTag)
oldContain?.removeFromSuperview()
Expand Down Expand Up @@ -215,10 +220,12 @@ public extension UIScrollView{

//Left
extension UIScrollView{
@discardableResult
public func setUpLeftRefresh(_ action:@escaping ()->())->DefaultRefreshLeft{
let left = DefaultRefreshLeft(frame: CGRect(x: 0,y: 0,width: PullToRefreshKitConst.defaultLeftWidth, height: self.frame.height))
return setUpLeftRefresh(left, action: action)
}
@discardableResult
public func setUpLeftRefresh<T:UIView>(_ left:T,action:@escaping ()->())->T where T:RefreshableLeftRight{
let oldContain = self.viewWithTag(PullToRefreshKitConst.leftTag)
oldContain?.removeFromSuperview()
Expand All @@ -237,10 +244,12 @@ extension UIScrollView{
}
//Right
extension UIScrollView{
@discardableResult
public func setUpRightRefresh(_ action:@escaping ()->())->DefaultRefreshRight{
let right = DefaultRefreshRight(frame: CGRect(x: 0 ,y: 0 ,width: PullToRefreshKitConst.defaultLeftWidth ,height: self.frame.height ))
return setUpRightRefresh(right, action: action)
}
@discardableResult
public func setUpRightRefresh<T:UIView>(_ right:T,action:@escaping ()->())->T where T:RefreshableLeftRight{
let oldContain = self.viewWithTag(PullToRefreshKitConst.rightTag)
oldContain?.removeFromSuperview()
Expand Down

0 comments on commit a3509f1

Please sign in to comment.