Skip to content

influitive/SHObjectUserInfo

 
 

Repository files navigation

SHObjectUserInfo

Overview

SHObjectUserInfo is a category on top of NSObject to allow userInfo dictionary without swizzling. It's built on top of NSMapTable that works with weakToStrong references between an object and its userInfo.

Swizzle & Junk free

No developer psyches were harmed or killed for this. I've noticed other similar libraries all swizzle like there is no tomorrow. If the API can remains the same without Swizzle, then don't fucking Swizzle.

All in all; 50 loc for userInfo

Installation

pod 'SHObjectUserInfo'

Setup

Put this either in specific classes or your project prefix file

#import 'NSObject+SHObjectUserInfo.h'

or

#import 'SHObjectUserInfo.h'

Usage

myObjectThatInheritedFromNSObject.sh_userInfo = [@{@"myKey" : mYValue} mutableCopy];

If you're using SHSegueBlocks

[self SH_performSegueWithIdentifier:@"unwinder" withUserInfo:@{@"date" : [NSDate date]}];

In the destinationViewController

self.myDate = self.SH_userInfo[@"date"];

or

  [self SH_performSegueWithIdentifier:@"push" 
        andDestionationViewController:^(UIViewController * theDestinationViewController) {

    theDestinationViewController.SH_userInfo = myDictionary

  }];

Contact

If you end up using SHSegueBlocks in a project, I'd love to hear about it.

email: seivan.heidari@icloud.com
twitter: @seivanheidari

License

SHSegueBlocks is © 2013 Seivan and may be freely distributed under the MIT license. See the LICENSE.md file.

About

NSObject prefixed userInfo without swizzling.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 49.5%
  • Ruby 33.2%
  • Shell 12.9%
  • C 4.4%