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

Commit 954db2b

Browse files
committed
Create protocols and implementations
To have more flexibility
1 parent fbc3542 commit 954db2b

19 files changed

+62
-36
lines changed

Library/Core/FileResource.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@
88

99
import Foundation
1010

11-
public struct FileResource {
11+
public protocol FileResourceType {
12+
13+
/// Bundle this file is in or nil for main bundle
14+
var bundle: NSBundle? { get }
15+
16+
/// Name of the file file on disk
17+
var name: String { get }
18+
19+
/// Extension of the file on disk
20+
var pathExtension: String { get }
21+
}
22+
23+
public struct FileResource: FileResourceType {
1224
/// Bundle this file is in or nil for main bundle
1325
public let bundle: NSBundle?
1426

Library/Core/FontResource.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@
88

99
import Foundation
1010

11-
public struct FontResource {
11+
public protocol FontResourceType {
1212
/// Name of the font
13-
let fontName: String
13+
var fontName: String { get }
14+
}
15+
16+
public struct FontResource: FontResourceType {
17+
/// Name of the font
18+
public let fontName: String
1419

1520
public init(fontName: String) {
1621
self.fontName = fontName

Library/Core/Identifier.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import Foundation
1010

1111
/// Base protocol for all identifiers
12-
public protocol Identifier: CustomStringConvertible {
12+
public protocol IdentifierType: CustomStringConvertible {
1313
/// Identifier string
1414
var identifier: String { get }
1515
}
1616

17-
extension Identifier {
17+
extension IdentifierType {
1818
/// CustomStringConvertible implementation, returns the identifier
1919
public var description: String {
2020
return identifier

Library/Core/ImageResource.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88

99
import Foundation
1010

11-
public struct ImageResource {
11+
public protocol ImageResourceType {
12+
13+
/// Bundle this image is in or nil for main bundle
14+
var bundle: NSBundle? { get }
15+
16+
/// Name of the image
17+
var name: String { get }
18+
}
19+
20+
public struct ImageResource: ImageResourceType {
1221

1322
/// Bundle this image is in or nil for main bundle
1423
public let bundle: NSBundle?

Library/Core/NibResource.swift

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

1111
/// Represents a nib file on disk
12-
public protocol NibResource {
12+
public protocol NibResourceType {
1313

1414
/// Bundle this nib is in or nil for main bundle
1515
var bundle: NSBundle? { get }

Library/Core/ReuseIdentifierProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import Foundation
1010

1111
/// Reuse identifier protocol
12-
public protocol ReuseIdentifierProtocol: Identifier {
12+
public protocol ReuseIdentifierType: IdentifierType {
1313
/// Type of this reuseable
1414
typealias ReusableType
1515
}
1616

1717
/// Reuse identifier
18-
public struct ReuseIdentifier<Reusable>: ReuseIdentifierProtocol {
18+
public struct ReuseIdentifier<Reusable>: ReuseIdentifierType {
1919
/// Type of this reuseable
2020
public typealias ReusableType = Reusable
2121

Library/Core/StoryboardResource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010
import UIKit
1111

12-
public protocol StoryboardResource {
12+
public protocol StoryboardResourceType {
1313

1414
/// Bundle this storyboard is in or nil for main bundle
1515
var bundle: NSBundle? { get }
@@ -18,7 +18,7 @@ public protocol StoryboardResource {
1818
var name: String { get }
1919
}
2020

21-
public protocol StoryboardResourceWithInitialController: StoryboardResource {
21+
public protocol StoryboardResourceWithInitialControllerType: StoryboardResourceType {
2222

2323
/// Type of the inital controller
2424
typealias InitialController

Library/Core/StoryboardSegueIdentifierProtocol.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
/// Segue identifier protocol
12-
public protocol StoryboardSegueIdentifierProtocol: Identifier {
12+
public protocol StoryboardSegueIdentifierType: IdentifierType {
1313
/// Type of the segue itself
1414
typealias SegueType
1515

@@ -21,7 +21,7 @@ public protocol StoryboardSegueIdentifierProtocol: Identifier {
2121
}
2222

2323
/// Segue identifier
24-
public struct StoryboardSegueIdentifier<Segue, Source, Destination>: StoryboardSegueIdentifierProtocol {
24+
public struct StoryboardSegueIdentifier<Segue, Source, Destination>: StoryboardSegueIdentifierType {
2525
/// Type of the segue itself
2626
public typealias SegueType = Segue
2727

@@ -45,7 +45,7 @@ public struct StoryboardSegueIdentifier<Segue, Source, Destination>: StoryboardS
4545
}
4646

4747
/// Typed segue information
48-
public struct TypedStoryboardSegueInfo<Segue, Source, Destination>: StoryboardSegueIdentifierProtocol {
48+
public struct TypedStoryboardSegueInfo<Segue, Source, Destination>: StoryboardSegueIdentifierType {
4949
/// Type of the segue itself
5050
public typealias SegueType = Segue
5151

Library/Foundation/NSBundle+FileResource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public extension NSBundle {
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: FileResource) -> NSURL? {
19+
public func URLForResource(resource: FileResourceType) -> NSURL? {
2020
return URLForResource(resource.name, withExtension: resource.pathExtension, subdirectory: nil, localization: nil)
2121
}
2222

@@ -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: FileResource) -> String? {
30+
public func pathForResource(resource: FileResourceType) -> String? {
3131
return pathForResource(resource.name, ofType: resource.pathExtension, inDirectory: nil, forLocalization: nil)
3232
}
3333
}

Library/UIKit/NibResource+UIKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import Foundation
1010

11-
public extension NibResource {
11+
public extension NibResourceType {
1212
/**
1313
Instantiate the nib to get the top-level objects from this nib
1414

0 commit comments

Comments
 (0)