Latest 2.1.1
Homepage https://github.com/Adorkable/SegueingInfo
License MIT
Platforms ios 9.1, osx 10.11, requires ARC
Authors

Build Status
Pod Platform
Pod License
Carthage compatible
Pod Version

SegueingInfo provides a few simple ways to passs data between segueing View Controller’s in both iOS and OSX UIStoryboards in a formal, declarative interface which enforcing modularity and weak dependancy between your View Controller implementations.

SegueingInfo requires minimal code to get up and running and using the sender parameter of your performSegueWithIdentifier(identifier:, sender:) function call (performSegueWithIdentifier:sender: selector in ObjC).

Installation

SegueingInfo is available through Carthage, to install simply add the following to your Cartfile:

github "Adorkable/SegueingInfo"

SegueingInfo is also available through Cocoapods, to install simply add the following line to your PodFile:

  pod "SegueingInfo"

Alternatively you can clone the github repo.

Setup

Once installed you’ll first want to import library:

Swift

import SegueingInfo

ObjC

#import <SegueingInfo/SeguingInfo.h>

Once set up, to pass information simply call the appropriate performSegueWithIdentifier, popViewController, etc. call and pass your information into the sender parameter:

Swift

...
self.performSegueWithIdentifier("Next", sender: someObjectWithInfo)
...

ObjC

...
[self performSegueWithIdentifier:"Next" sender:someObjectWithInfo];
...

Next your destination UIViewController subclass must conform to the protocol SegueingInfoDestination, it will receive the information you pass, through the selector

Swift

func destinationPrepareForSegue(segue : UIStoryboardSegue?, info: AnyObject) {
    ...
}

ObjC

- (void)destinationPrepareForSegue:(UIStoryboardSegue *)segue info:(id)info
{
    ...
}

Please note: there is no guarantee as to when your destination View Controller will receive the information relative to viewDidLoad. If you plan on using the passed information to populate your interface make sure you use it when viewDidLoad has been called and store it off when it hasn’t yet.

Note: there are plans to provide a more guaranteed handling of this.

Finally you have two options:

  1. You can change your source UIViewController‘s parent class to SegueingInfoViewController to have it automatically forward your information on segue.

  2. The UIViewController (SegueingInfo) category provides the class selector prepareDestinationViewControllerForSegue for forwarding your info on to the destination UIViewController manually. Typically you’ll be calling this from your UIViewController‘s prepareForSegue:

    Swift

    override func prepareForSegue(segue : UIStoryboardSegue, sender : AnyObject?) {
        super.prepareForSegue(segue, sender: sender)
    
        self.prepareDestinationViewControlleForSegue(segue, sender: sender)
    }

    ObjC

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    {
        [super prepareForSegue:segue sender:sender];
    
        [self prepareDestinationViewControllerForSegue:segue withInfo:sender];
    }

Contributing

If you have any ideas, suggestions or bugs to report please create an issue labeled feature or bug (check to see if the issue exists first please!). Or suggest a pull request!

waffle.io

Latest podspec

{
    "name": "SegueingInfo",
    "version": "2.1.1",
    "summary": "Simple way to pass data between segueing View Controllers.",
    "description": "**SegueingInfo** provides a simple interface, category, and class for passing data between segueing *UIViewController*s in iOS and OSX *UIStoryboard*s using the `sender` parameter of the `performSegueWithIdentifier:sender:` selector.",
    "homepage": "https://github.com/Adorkable/SegueingInfo",
    "license": "MIT",
    "authors": {
        "Ian G": "[email protected]"
    },
    "platforms": {
        "ios": "9.1",
        "osx": "10.11"
    },
    "source": {
        "git": "https://github.com/Adorkable/SegueingInfo.git",
        "tag": "2.1.1"
    },
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "2.3"
    },
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Sources/**/*.swift"
        }
    ]
}

Pin It on Pinterest

Share This