Skip to content

Commit

Permalink
Improve Swift syntax (#25)
Browse files Browse the repository at this point in the history
* Replace init-ializable struct with enums

* Add AnyObject requirement to protocols

* Hide init?(coder aDecoder: NSCoder) func

* Improve Swift syntax

* Revert "Replace init-ializable struct with enums"

This reverts commit 1be2e8c.
  • Loading branch information
giulio92 authored and TosinAF committed May 17, 2019
1 parent a9edeb1 commit b0fb9e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion PanModal/Presentable/PanModalPresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import UIKit
}
```
*/
public protocol PanModalPresentable {
public protocol PanModalPresentable: AnyObject {

/**
The scroll view embedded in the view controller.
Expand Down
2 changes: 1 addition & 1 deletion PanModal/Presenter/PanModalPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import UIKit
sourceRect: .zero)
```
*/
protocol PanModalPresenter {
protocol PanModalPresenter: AnyObject {

/**
A flag that returns true if the current presented view controller
Expand Down
7 changes: 5 additions & 2 deletions PanModal/View/PanContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class PanContainerView: UIView {
addSubview(presentedView)
}

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError()
fatalError("init(coder:) has not been implemented")
}

}
Expand All @@ -33,7 +34,9 @@ extension UIView {
from the view hierachy
*/
var panContainerView: PanContainerView? {
return subviews.compactMap({ $0 as? PanContainerView }).first
return subviews.first(where: { view -> Bool in
view is PanContainerView
}) as? PanContainerView
}

}

0 comments on commit b0fb9e7

Please sign in to comment.