Skip to content

seivan/SHObjectUserInfo

Repository files navigation

SHObjectUserInfo

CI Status Version Platform License

This pod is used by SHFoundationAdditions as part of many components covering to plug the holes missing from Foundation, UIKit, CoreLocation, GameKit, MapKit and other aspects of an iOS application's architecture.

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 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 SHObjectUserInfo in a project, I'd love to hear about it.

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

License

SHObjectUserInfo 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