Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit fe1785e

Browse files
committed
Run Swift 3 conversion
1 parent 326e89b commit fe1785e

17 files changed

+73
-74
lines changed

Library/Core/FileResource.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public protocol FileResourceType {
1212

1313
/// Bundle this file is in
14-
var bundle: NSBundle { get }
14+
var bundle: Bundle { get }
1515

1616
/// Name of the file file on disk
1717
var name: String { get }
@@ -23,7 +23,7 @@ public protocol FileResourceType {
2323
public extension FileResourceType {
2424
/// Name of the file on disk with the pathExtension
2525
var fullName: String {
26-
return [name, pathExtension].joinWithSeparator(".")
26+
return [name, pathExtension].joined(separator: ".")
2727
}
2828

2929
/**
@@ -40,22 +40,22 @@ public extension FileResourceType {
4040

4141
- returns: The file URL for this resource or nil if the file could not be located.
4242
*/
43-
func url() -> NSURL? {
43+
func url() -> URL? {
4444
return bundle.URLForResource(self)
4545
}
4646
}
4747

4848
public struct FileResource: FileResourceType {
4949
/// Bundle this file is in
50-
public let bundle: NSBundle
50+
public let bundle: Bundle
5151

5252
/// Name of the file on disk, without the pathExtension
5353
public let name: String
5454

5555
/// Extension of the file on disk
5656
public let pathExtension: String
5757

58-
public init(bundle: NSBundle, name: String, pathExtension: String) {
58+
public init(bundle: Bundle, name: String, pathExtension: String) {
5959
self.bundle = bundle
6060
self.name = name
6161
self.pathExtension = pathExtension

Library/Core/ImageResource.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public protocol ImageResourceType {
1212

1313
/// Bundle this image is in
14-
var bundle: NSBundle { get }
14+
var bundle: Bundle { get }
1515

1616
/// Name of the image
1717
var name: String { get }
@@ -20,12 +20,12 @@ public protocol ImageResourceType {
2020
public struct ImageResource: ImageResourceType {
2121

2222
/// Bundle this image is in
23-
public let bundle: NSBundle
23+
public let bundle: Bundle
2424

2525
/// Name of the image
2626
public let name: String
2727

28-
public init(bundle: NSBundle, name: String) {
28+
public init(bundle: Bundle, name: String) {
2929
self.bundle = bundle
3030
self.name = name
3131
}

Library/Core/NibResource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212
public protocol NibResourceType {
1313

1414
/// Bundle this nib is in or nil for main bundle
15-
var bundle: NSBundle { get }
15+
var bundle: Bundle { get }
1616

1717
/// Name of the nib file on disk
1818
var name: String { get }

Library/Core/StoryboardResource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
public protocol StoryboardResourceType {
1212

1313
/// Bundle this storyboard is in
14-
var bundle: NSBundle { get }
14+
var bundle: Bundle { get }
1515

1616
/// Name of the storyboard file on disk
1717
var name: String { get }

Library/Core/StoryboardSegueIdentifierProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public struct StoryboardSegueIdentifier<Segue, Source, Destination>: StoryboardS
4444
}
4545

4646
/// Create a new StoryboardSegue based on the identifier and source view controller
47-
public func storyboardSegueWithSource(sourceViewController: Source)
47+
public func storyboardSegueWithSource(_ sourceViewController: Source)
4848
-> StoryboardSegue<Segue, Source, Destination>
4949
{
5050
return StoryboardSegue(identifier: self, sourceViewController: sourceViewController)

Library/Core/Validatable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
/// Error thrown during validation
12-
public struct ValidationError: ErrorType, CustomStringConvertible {
12+
public struct ValidationError: ErrorProtocol, CustomStringConvertible {
1313
/// Human readable description
1414
public let description: String
1515

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSBundle+FileResource.swift
2+
// Bundle+FileResource.swift
33
// R.swift.Library
44
//
55
// Created by Mathijs Kadijk on 10-01-16.
@@ -8,16 +8,16 @@
88

99
import Foundation
1010

11-
public extension NSBundle {
11+
public extension Bundle {
1212
/**
1313
Returns the file URL for the given resource (R.file.*).
1414

1515
- parameter resource: The resource to get the file URL for (R.file.*).
1616

1717
- returns: The file URL for the resource file (R.file.*) or nil if the file could not be located.
1818
*/
19-
public func URLForResource(resource: FileResourceType) -> NSURL? {
20-
return URLForResource(resource.name, withExtension: resource.pathExtension)
19+
public func URLForResource(_ resource: FileResourceType) -> URL? {
20+
return urlForResource(resource.name, withExtension: resource.pathExtension)
2121
}
2222

2323
/**
@@ -27,7 +27,7 @@ public extension NSBundle {
2727

2828
- returns: The full pathname for the resource file (R.file.*) or nil if the file could not be located.
2929
*/
30-
public func pathForResource(resource: FileResourceType) -> String? {
30+
public func pathForResource(_ resource: FileResourceType) -> String? {
3131
return pathForResource(resource.name, ofType: resource.pathExtension)
3232
}
3333
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// NSData+FileResource.swift
2+
// Data+FileResource.swift
33
// R.swift.Library
44
//
55
// Created by Tom Lokhorst on 2016-03-11.
@@ -8,7 +8,7 @@
88

99
import Foundation
1010

11-
public extension NSData {
11+
public extension Data {
1212

1313
/**
1414
Creates and returns NSData with the contents of the specified file resource (R.file.*).
@@ -17,8 +17,8 @@ public extension NSData {
1717

1818
- returns: A NSData object with the contents of the specified file.
1919
*/
20-
public convenience init?(resource: FileResourceType) {
20+
public init?(resource: FileResourceType) throws {
2121
guard let url = resource.url() else { return nil }
22-
self.init(contentsOfURL: url)
22+
try self.init(contentsOf: url)
2323
}
2424
}

Library/UIKit/NibResource+UIKit.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public extension NibResourceType {
1818

1919
- returns: An array containing the top-level objects from the NIB
2020
*/
21-
public func instantiateWithOwner(ownerOrNil: AnyObject?, options optionsOrNil: [NSObject : AnyObject]? = nil) -> [AnyObject] {
22-
return UINib(resource: self).instantiateWithOwner(ownerOrNil, options: optionsOrNil)
21+
public func instantiateWithOwner(_ ownerOrNil: AnyObject?, options optionsOrNil: [NSObject : AnyObject]? = nil) -> [AnyObject] {
22+
return UINib(resource: self).instantiate(withOwner: ownerOrNil, options: optionsOrNil)
2323
}
2424
}

Library/UIKit/TypedStoryboardSegueInfo+UIStoryboardSegue.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ extension TypedStoryboardSegueInfo {
1717
*/
1818
public init?<SegueIdentifier: StoryboardSegueIdentifierType where SegueIdentifier.SegueType == Segue, SegueIdentifier.SourceType == Source, SegueIdentifier.DestinationType == Destination>(segueIdentifier: SegueIdentifier, segue: UIStoryboardSegue) {
1919
guard let identifier = segue.identifier,
20-
sourceViewController = segue.sourceViewController as? SegueIdentifier.SourceType,
21-
destinationViewController = segue.destinationViewController as? SegueIdentifier.DestinationType,
22-
segue = segue as? SegueIdentifier.SegueType
23-
where identifier == segueIdentifier.identifier
24-
else {
25-
return nil
20+
let sourceViewController = segue.sourceViewController as? SegueIdentifier.SourceType,
21+
let destinationViewController = segue.destinationViewController as? SegueIdentifier.DestinationType,
22+
let segue = segue as? SegueIdentifier.SegueType, identifier == segueIdentifier.identifier
23+
else {
24+
return nil
2625
}
2726

2827
self.segue = segue

0 commit comments

Comments
 (0)