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.
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
pod 'SHObjectUserInfo'
Put this either in specific classes or your project prefix file
#import 'NSObject+SHObjectUserInfo.h'
or
#import 'SHObjectUserInfo.h'
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
}];
If you end up using SHSegueBlocks in a project, I'd love to hear about it.
email: seivan.heidari@icloud.com
twitter: @seivanheidari
SHSegueBlocks is © 2013 Seivan and may be freely
distributed under the MIT license.
See the LICENSE.md
file.