diff --git a/.swift-version b/.swift-version index 9f55b2c..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/Library/Foundation/Bundle+FileResource.swift b/Library/Foundation/Bundle+FileResource.swift index 83af4ff..d632c8d 100644 --- a/Library/Foundation/Bundle+FileResource.swift +++ b/Library/Foundation/Bundle+FileResource.swift @@ -17,7 +17,7 @@ public extension Bundle { - returns: The file URL for the resource file (R.file.*) or nil if the file could not be located. */ - public func url(forResource resource: FileResourceType) -> URL? { + func url(forResource resource: FileResourceType) -> URL? { return url(forResource: resource.name, withExtension: resource.pathExtension) } @@ -28,7 +28,7 @@ public extension Bundle { - returns: The full pathname for the resource file (R.file.*) or nil if the file could not be located. */ - public func path(forResource resource: FileResourceType) -> String? { + func path(forResource resource: FileResourceType) -> String? { return path(forResource: resource.name, ofType: resource.pathExtension) } } diff --git a/Library/Foundation/Data+FileResource.swift b/Library/Foundation/Data+FileResource.swift index 2f612bd..36a0a36 100644 --- a/Library/Foundation/Data+FileResource.swift +++ b/Library/Foundation/Data+FileResource.swift @@ -20,7 +20,7 @@ public extension Data { - returns: A NSData object with the contents of the specified file. */ - public init(resource: FileResourceType) throws { + init(resource: FileResourceType) throws { guard let url = resource.url() else { throw NoUrlForResourceError() } try self.init(contentsOf: url) } diff --git a/Library/UIKit/NibResource+UIKit.swift b/Library/UIKit/NibResource+UIKit.swift index eada71d..4339d3f 100644 --- a/Library/UIKit/NibResource+UIKit.swift +++ b/Library/UIKit/NibResource+UIKit.swift @@ -19,7 +19,7 @@ public extension NibResourceType { - returns: An array containing the top-level objects from the NIB */ - public func instantiate(withOwner ownerOrNil: Any?, options optionsOrNil: [UINib.OptionsKey : Any]? = [:]) -> [Any] { + func instantiate(withOwner ownerOrNil: Any?, options optionsOrNil: [UINib.OptionsKey : Any]? = [:]) -> [Any] { return UINib(resource: self).instantiate(withOwner: ownerOrNil, options: optionsOrNil) } } diff --git a/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift b/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift index 23f4f46..b5b114c 100644 --- a/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift +++ b/Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift @@ -16,7 +16,7 @@ public extension StoryboardResourceWithInitialControllerType { - returns: The initial view controller in the storyboard. */ - public func instantiateInitialViewController() -> InitialController? { + func instantiateInitialViewController() -> InitialController? { return UIStoryboard(resource: self).instantiateInitialViewController() as? InitialController } } diff --git a/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift b/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift index aabcf14..bf68fa1 100644 --- a/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift +++ b/Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift @@ -19,7 +19,7 @@ public extension UICollectionView { - returns: A subclass of UICollectionReusableView or nil if the cast fails. */ - public func dequeueReusableCell(withReuseIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? + func dequeueReusableCell(withReuseIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? where Identifier.ReusableType: UICollectionReusableView { return dequeueReusableCell(withReuseIdentifier: identifier.identifier, for: indexPath) as? Identifier.ReusableType @@ -34,7 +34,7 @@ public extension UICollectionView { - returns: A subclass of UICollectionReusableView or nil if the cast fails. */ - public func dequeueReusableSupplementaryView(ofKind elementKind: String, withReuseIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? + func dequeueReusableSupplementaryView(ofKind elementKind: String, withReuseIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? where Identifier.ReusableType: UICollectionReusableView { return dequeueReusableSupplementaryView(ofKind: elementKind, withReuseIdentifier: identifier.identifier, for: indexPath) as? Identifier.ReusableType @@ -45,7 +45,7 @@ public extension UICollectionView { - parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionViewCell that has a reuse identifier */ - public func register(_ nibResource: Resource) + func register(_ nibResource: Resource) where Resource.ReusableType: UICollectionViewCell { register(UINib(resource: nibResource), forCellWithReuseIdentifier: nibResource.identifier) @@ -56,7 +56,7 @@ public extension UICollectionView { - parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionReusableView. that has a reuse identifier */ - public func register(_ nibResource: Resource, forSupplementaryViewOfKind kind: String) + func register(_ nibResource: Resource, forSupplementaryViewOfKind kind: String) where Resource.ReusableType: UICollectionReusableView { register(UINib(resource: nibResource), forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource.identifier) diff --git a/Library/UIKit/UIColor+ColorResource.swift b/Library/UIKit/UIColor+ColorResource.swift index 800d338..3bd7313 100644 --- a/Library/UIKit/UIColor+ColorResource.swift +++ b/Library/UIKit/UIColor+ColorResource.swift @@ -20,7 +20,7 @@ public extension UIColor { - returns: A color that exactly or best matches the desired traits with the given resource (R.color.*), or nil if no suitable color was found. */ - public convenience init?(resource: ColorResourceType, compatibleWith traitCollection: UITraitCollection? = nil) { + convenience init?(resource: ColorResourceType, compatibleWith traitCollection: UITraitCollection? = nil) { self.init(named: resource.name, in: resource.bundle, compatibleWith: traitCollection) } } diff --git a/Library/UIKit/UIFont+FontResource.swift b/Library/UIKit/UIFont+FontResource.swift index 237d9cf..cadc6c9 100644 --- a/Library/UIKit/UIFont+FontResource.swift +++ b/Library/UIKit/UIFont+FontResource.swift @@ -19,7 +19,7 @@ public extension UIFont { - returns: A font object of the specified font resource and size. */ - public convenience init?(resource: FontResourceType, size: CGFloat) { + convenience init?(resource: FontResourceType, size: CGFloat) { self.init(name: resource.fontName, size: size) } } diff --git a/Library/UIKit/UIImage+ImageResource.swift b/Library/UIKit/UIImage+ImageResource.swift index 6037b4f..f96fa14 100644 --- a/Library/UIKit/UIImage+ImageResource.swift +++ b/Library/UIKit/UIImage+ImageResource.swift @@ -18,7 +18,7 @@ public extension UIImage { - returns: An image that exactly or best matches the desired traits with the given resource (R.image.*), or nil if no suitable image was found. */ - public convenience init?(resource: ImageResourceType, compatibleWith traitCollection: UITraitCollection? = nil) { + convenience init?(resource: ImageResourceType, compatibleWith traitCollection: UITraitCollection? = nil) { self.init(named: resource.name, in: resource.bundle, compatibleWith: traitCollection) } } diff --git a/Library/UIKit/UINib+NibResource.swift b/Library/UIKit/UINib+NibResource.swift index 70cba8a..73bb048 100644 --- a/Library/UIKit/UINib+NibResource.swift +++ b/Library/UIKit/UINib+NibResource.swift @@ -17,7 +17,7 @@ public extension UINib { - returns: The initialized UINib object. An exception is thrown if there were errors during initialization or the nib file could not be located. */ - public convenience init(resource: NibResourceType) { + convenience init(resource: NibResourceType) { self.init(nibName: resource.name, bundle: resource.bundle) } } diff --git a/Library/UIKit/UIStoryboard+StoryboardResource.swift b/Library/UIKit/UIStoryboard+StoryboardResource.swift index bc03c2e..8848be0 100644 --- a/Library/UIKit/UIStoryboard+StoryboardResource.swift +++ b/Library/UIKit/UIStoryboard+StoryboardResource.swift @@ -17,7 +17,7 @@ public extension UIStoryboard { - returns: A storyboard object for the specified file. If no storyboard resource file matching name exists, an exception is thrown with description: `Could not find a storyboard named 'XXXXXX' in bundle....` */ - public convenience init(resource: StoryboardResourceType) { + convenience init(resource: StoryboardResourceType) { self.init(name: resource.name, bundle: resource.bundle) } } diff --git a/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift b/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift index f816d62..59adab3 100644 --- a/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift +++ b/Library/UIKit/UIStoryboard+StoryboardViewControllerResource.swift @@ -18,7 +18,7 @@ public extension UIStoryboard { - returns: The view controller corresponding to the specified resource (R.storyboard.*.*). If no view controller is associated, this method throws an exception. */ - public func instantiateViewController(withResource resource: ViewControllerResource) -> ViewControllerResource.ViewControllerType? { + func instantiateViewController(withResource resource: ViewControllerResource) -> ViewControllerResource.ViewControllerType? { return self.instantiateViewController(withIdentifier: resource.identifier) as? ViewControllerResource.ViewControllerType } } diff --git a/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift b/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift index c5202ee..10d4b4f 100644 --- a/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift +++ b/Library/UIKit/UITableView+ReuseIdentifierProtocol.swift @@ -21,14 +21,14 @@ public extension UITableView { - precondition: You must register a class or nib file using the registerNib: or registerClass:forCellReuseIdentifier: method before calling this method. */ - public func dequeueReusableCell(withIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? + func dequeueReusableCell(withIdentifier identifier: Identifier, for indexPath: IndexPath) -> Identifier.ReusableType? where Identifier.ReusableType: UITableViewCell { return dequeueReusableCell(withIdentifier: identifier.identifier, for: indexPath) as? Identifier.ReusableType } @available(*, unavailable, message: "Use dequeueReusableCell(withIdentifier:for:) instead") - public func dequeueReusableCell(withIdentifier identifier: Identifier) -> Identifier.ReusableType? + func dequeueReusableCell(withIdentifier identifier: Identifier) -> Identifier.ReusableType? where Identifier.ReusableType: UITableViewCell { fatalError() @@ -41,7 +41,7 @@ public extension UITableView { - returns: A UITableViewHeaderFooterView object with the associated identifier or nil if no such object exists in the reusable view queue or if it couldn't be cast correctly. */ - public func dequeueReusableHeaderFooterView(withIdentifier identifier: Identifier) -> Identifier.ReusableType? + func dequeueReusableHeaderFooterView(withIdentifier identifier: Identifier) -> Identifier.ReusableType? where Identifier.ReusableType: UITableViewHeaderFooterView { return dequeueReusableHeaderFooterView(withIdentifier: identifier.identifier) as? Identifier.ReusableType @@ -52,7 +52,7 @@ public extension UITableView { - parameter nibResource: A nib resource (R.nib.*) containing a table view cell that has a reuse identifier */ - public func register(_ nibResource: Resource) where Resource.ReusableType: UITableViewCell { + func register(_ nibResource: Resource) where Resource.ReusableType: UITableViewCell { register(UINib(resource: nibResource), forCellReuseIdentifier: nibResource.identifier) } @@ -61,7 +61,7 @@ public extension UITableView { - parameter nibResource: A nib resource (R.nib.*) containing a view that has a reuse identifier */ - public func registerHeaderFooterView(_ nibResource: Resource) where Resource: ReuseIdentifierType, Resource.ReusableType: UIView { + func registerHeaderFooterView(_ nibResource: Resource) where Resource: ReuseIdentifierType, Resource.ReusableType: UIView { register(UINib(resource: nibResource), forHeaderFooterViewReuseIdentifier: nibResource.identifier) } } diff --git a/Library/UIKit/UIViewController+NibResource.swift b/Library/UIKit/UIViewController+NibResource.swift index 38c24ca..dbef8ce 100644 --- a/Library/UIKit/UIViewController+NibResource.swift +++ b/Library/UIKit/UIViewController+NibResource.swift @@ -18,7 +18,7 @@ public extension UIViewController { - returns: A newly initialized UIViewController object. */ - public convenience init(nib: NibResourceType) { + convenience init(nib: NibResourceType) { self.init(nibName: nib.name, bundle: nib.bundle) } } diff --git a/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift b/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift index 6c886b4..27364a4 100644 --- a/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift +++ b/Library/UIKit/UIViewController+StoryboardSegueIdentifierProtocol.swift @@ -23,7 +23,7 @@ public extension SeguePerformerType { - parameter sender: The object that you want to use to initiate the segue. This object is made available for informational purposes during the actual segue. - SeeAlso: Library for typed block based segues: [tomlokhorst/SegueManager](https://github.com/tomlokhorst/SegueManager) */ - public func performSegue(withIdentifier identifier: StoryboardSegueIdentifier, sender: Any?) { + func performSegue(withIdentifier identifier: StoryboardSegueIdentifier, sender: Any?) { performSegue(withIdentifier: identifier.identifier, sender: sender) } } @@ -33,7 +33,7 @@ public extension StoryboardSegue where Source : UIViewController { Performs this segue on the source view controller - parameter sender: The object that you want to use to initiate the segue. This object is made available for informational purposes during the actual segue. */ - public func performSegue(sender: Any? = nil) { + func performSegue(sender: Any? = nil) { source.performSegue(withIdentifier: identifier.identifier, sender: sender) } }