Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added instantiateInitialViewController to TyphoonStoryboard #192

Merged
merged 3 commits into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Source/ios/Storyboard/TyphoonStoryboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ @implementation TyphoonStoryboard

+ (TyphoonStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil
{
return [super storyboardWithName:name bundle:storyboardBundleOrNil];
return (TyphoonStoryboard *)[super storyboardWithName:name bundle:storyboardBundleOrNil];
}

+ (TyphoonStoryboard *)storyboardWithName:(NSString *)name factory:(TyphoonComponentFactory *)factory bundle:(NSBundle *)bundleOrNil
Expand All @@ -57,6 +57,17 @@ + (TyphoonStoryboard *)storyboardWithName:(NSString *)name factory:(TyphoonCompo
return storyboard;
}

- (id)instantiateInitialViewController
{
NSAssert(self.factory, @"TyphoonStoryboard's factory property can't be nil!");

id viewController = [super instantiateInitialViewController];

[self injectPropertiesForViewController:viewController];

return viewController;
}

- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier
{
NSAssert(self.factory, @"TyphoonStoryboard's factory property can't be nil!");
Expand Down
23 changes: 22 additions & 1 deletion Tests/Definition/Storyboard/Storyboard.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="h33-p8-fk0">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="Mg8-lN-kDC">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="8mH-c4-GYO">
<objects>
<viewController id="Mg8-lN-kDC" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="uax-1o-dQS"/>
<viewControllerLayoutGuide type="bottom" id="AcU-2s-gVU"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="aws-vV-SIt">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="typhoonKey" value="initialViewController"/>
</userDefinedRuntimeAttributes>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HOr-A4-dLf" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-179" y="-820"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="ZHQ-UY-3uY">
<objects>
Expand Down
6 changes: 6 additions & 0 deletions Tests/Definition/Storyboard/StoryboardTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ - (void)setUp
storyboard = [TyphoonStoryboard storyboardWithName:@"Storyboard" factory:factory bundle:bundle];
}

- (void)test_initial
{
UIViewController *controller = [storyboard instantiateInitialViewController];
STAssertEqualObjects(controller.title, @"Initial", nil);
}

- (void)test_first
{
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"first"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@interface StoryboardViewControllerAssembly : TyphoonAssembly

- (id) initialViewController;
- (id) firstViewController;
- (id) secondViewController;
- (id) uniqueViewController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

@implementation StoryboardViewControllerAssembly

- (id) initialViewController
{
return [TyphoonDefinition withClass:[UIViewController class] properties:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(title) withObjectInstance:@"Initial"];
}];
}

- (id) firstViewController
{
return [TyphoonDefinition withClass:[UIViewController class] properties:^(TyphoonDefinition *definition) {
Expand Down