This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
125 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// StoryboardResource.swift | ||
// R.swift.Library | ||
// | ||
// Created by Mathijs Kadijk on 07-01-16. | ||
// Copyright © 2016 Mathijs Kadijk. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
|
||
public protocol StoryboardResource { | ||
|
||
/// Bundle this storyboard is in or nil for main bundle | ||
var bundle: NSBundle? { get } | ||
|
||
/// Name of the storyboard file on disk | ||
var name: String { get } | ||
} | ||
|
||
public protocol StoryboardResourceWithInitialController: StoryboardResource { | ||
|
||
/// Type of the inital controller | ||
typealias InitialController | ||
} |
20 changes: 20 additions & 0 deletions
20
Library/UIKit/StoryboardResourceWithInitialController+UIKit.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// StoryboardResourceWithInitialController+UIKit.swift | ||
// R.swift.Library | ||
// | ||
// Created by Mathijs Kadijk on 07-01-16. | ||
// Copyright © 2016 Mathijs Kadijk. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension StoryboardResourceWithInitialController { | ||
/** | ||
Instantiates and returns the initial view controller in the view controller graph. | ||
- returns: The initial view controller in the storyboard. | ||
*/ | ||
public func initialViewController() -> InitialController? { | ||
return UIStoryboard(resource: self).instantiateInitialViewController() as? InitialController | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// UINib+NibResource.swift | ||
// R.swift.Library | ||
// | ||
// Created by Mathijs Kadijk on 08-01-16. | ||
// Copyright © 2016 Mathijs Kadijk. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UINib { | ||
/** | ||
Returns a UINib object initialized to the nib file of the specified resource (R.nib.*). | ||
- parameter resource: The resource (R.nib.*) to load | ||
- returns: The initialized UINib object. An exception is thrown if there were errors during initialization or the nib file could not be located. | ||
*/ | ||
convenience init(resource: NibResource) { | ||
self.init(nibName: resource.name, bundle: resource.bundle) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// UIStoryboard+StoryboardResource.swift | ||
// R.swift.Library | ||
// | ||
// Created by Mathijs Kadijk on 07-01-16. | ||
// Copyright © 2016 Mathijs Kadijk. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIStoryboard { | ||
/** | ||
Creates and returns a storyboard object for the specified storyboard resource (R.storyboard.*) file. | ||
- parameter resource: The storyboard resource (R.storyboard.*) for the specific storyboard to load | ||
- 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: StoryboardResource) { | ||
self.init(name: resource.name, bundle: resource.bundle) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters