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

Commit 7d145f5

Browse files
committed
Implement initialize and instantiate nib methods
in extension.
1 parent 86ef867 commit 7d145f5

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Library/Core/NibResource.swift

+19-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,27 @@ public protocol NibResource {
1616

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

21+
public extension NibResource {
2022
/**
2123
Create a new instance of this nib file
22-
24+
2325
- returns: A new instance of this nib
24-
*/
25-
func initialize() -> UINib
26+
*/
27+
public func initialize() -> UINib {
28+
return UINib.init(nibName: name, bundle: bundle)
29+
}
30+
31+
/**
32+
Instantiate the nib to get the top-level object from this nib
33+
34+
- parameter ownerOrNil: The owner, if the owner parameter is nil, connections to File's Owner are not permitted.
35+
- parameter options: Options are identical to the options specified with -[NSBundle loadNibNamed:owner:options:]
36+
37+
- returns: An array containing the top-level objects from the NIB
38+
*/
39+
public func instantiateWithOwner(ownerOrNil: AnyObject?, options optionsOrNil: [NSObject : AnyObject]?) -> [AnyObject] {
40+
return initialize().instantiateWithOwner(ownerOrNil, options: optionsOrNil)
41+
}
2642
}

0 commit comments

Comments
 (0)