Skip to content

Commit

Permalink
Made a convenient way to access a containing storyboard link.
Browse files Browse the repository at this point in the history
Fixes issue #9.
  • Loading branch information
rob-brown committed Jan 26, 2014
1 parent 55681f9 commit 3d55541
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LinkedStoryboards/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
platform :ios, '7.0'

# :path refers to the local copy for development.
pod 'RBStoryboardLink', :path => '..'
pod 'RBStoryboardLink', :path => '../RBStoryboardLink.podspec'

# Conditional includes for the KIF tests.
# It is important that we don't include KIF in the main app.
Expand Down
10 changes: 5 additions & 5 deletions LinkedStoryboards/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PODS:
- KIF (2.0.0)
- RBStoryboardLink (0.0.6)
- RBStoryboardLink (0.0.8)

DEPENDENCIES:
- KIF (~> 2.0)
- RBStoryboardLink (from `..`)
- RBStoryboardLink (from `../RBStoryboardLink.podspec`)

EXTERNAL SOURCES:
RBStoryboardLink:
:path: ..
:path: ../RBStoryboardLink.podspec

SPEC CHECKSUMS:
KIF: ff3b46deb62ce3f8e99c6a2c786729e1eea241ba
RBStoryboardLink: f0f6cbc78a87c853d038017be4231e6e574c97ae
RBStoryboardLink: 1bcff9be9fa9de9d66ea10518a327be1af729d03

COCOAPODS: 0.28.0
COCOAPODS: 0.29.0
2 changes: 1 addition & 1 deletion LinkedTabs/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
platform :ios, '7.0'

# :path refers to the local copy for development.
pod 'RBStoryboardLink', :path => '..'
pod 'RBStoryboardLink', :path => '../RBStoryboardLink.podspec'

# Conditional includes for the KIF tests.
# It is important that we don't include KIF in the main app.
Expand Down
10 changes: 5 additions & 5 deletions LinkedTabs/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PODS:
- KIF (2.0.0)
- RBStoryboardLink (0.0.6)
- RBStoryboardLink (0.0.8)

DEPENDENCIES:
- KIF (~> 2.0)
- RBStoryboardLink (from `..`)
- RBStoryboardLink (from `../RBStoryboardLink.podspec`)

EXTERNAL SOURCES:
RBStoryboardLink:
:path: ..
:path: ../RBStoryboardLink.podspec

SPEC CHECKSUMS:
KIF: ff3b46deb62ce3f8e99c6a2c786729e1eea241ba
RBStoryboardLink: f0f6cbc78a87c853d038017be4231e6e574c97ae
RBStoryboardLink: 1bcff9be9fa9de9d66ea10518a327be1af729d03

COCOAPODS: 0.28.0
COCOAPODS: 0.29.0
8 changes: 4 additions & 4 deletions RBStoryboardLink.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RBStoryboardLink'
s.version = '0.0.7'
s.version = '0.0.8'
s.summary = 'Makes transitioning between storyboards possible.'
s.homepage = 'https://github.com/rob-brown/RBStoryboardLink'
s.license = {
Expand All @@ -10,11 +10,11 @@ Pod::Spec.new do |s|
s.author = 'Robert Brown'
s.source = {
:git => 'https://github.com/rob-brown/RBStoryboardLink.git',
:tag => '0.0.7'
:tag => '0.0.8'
}
s.platform = :ios, '7.0'
s.source_files = 'RBStoryboardLink.{h,m}', 'RBStoryboardLinkSource.h'
s.public_header_files = 'RBStoryboardLink.h', 'RBStoryboardLinkSource.h'
s.source_files = 'RBStoryboardLink.{h,m}', 'UIViewController+RBStoryboardLink.{h,m}', 'RBStoryboardLinkSource.h'
s.public_header_files = 'RBStoryboardLink.h', 'UIViewController+RBStoryboardLink.h', 'RBStoryboardLinkSource.h'
s.frameworks = 'UIKit'
s.requires_arc = true
end
27 changes: 27 additions & 0 deletions UIViewController+RBStoryboardLink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// UIViewController+RBStoryboardLink.h
// Pods
//
// Created by Robert Brown on 1/25/14.
//
//

#import <UIKit/UIKit.h>

@class RBStoryboardLink;


@interface UIViewController (RBStoryboardLink)

/// Returns the storyboard link this view controller is contained in, if any.
- (RBStoryboardLink *)rbsl_storyboardLink;

/**
* If the view controller is within a storyboard link, the link is returned.
* If not, `self` is returned. The intent is to access certain visual elements
* (such as `toolbarItems`) on the proper view controller when it's unknown if
* the view controller is contained in a link.
*/
- (UIViewController *)rbsl_targetViewController;

@end
26 changes: 26 additions & 0 deletions UIViewController+RBStoryboardLink.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UIViewController+RBStoryboardLink.m
// Pods
//
// Created by Robert Brown on 1/25/14.
//
//

#import "UIViewController+RBStoryboardLink.h"
#import "RBStoryboardLink.h"

@implementation UIViewController (RBStoryboardLink)

- (RBStoryboardLink *)rbsl_storyboardLink {

if ([self isKindOfClass:[RBStoryboardLink class]])
return (RBStoryboardLink *)self;

return [self.parentViewController rbsl_storyboardLink];
}

- (UIViewController *)rbsl_targetViewController {
return [self rbsl_storyboardLink] ?: self;
}

@end

0 comments on commit 3d55541

Please sign in to comment.