此 pod 是作为许多组成部分的一部分由
SHFoundationAdditions
使用的,这些组成部分用于填补 Foundation、UIKit、CoreLocation、GameKit、MapKit 以及 iOS 应用程序架构其他方面的空白。
SHObjectUserInfo 是基于 NSObject 的类别,允许无需 swizzling 即可获得 userInfo 字典。它建立在 NSMapTable 之上,该表在对象和其 userInfo 之间使用弱到强引用。
没有开发者因为这次修改而心灰意冷或丧失性命。我注意到其他类似的库所有者都像明天就要到来一样进行 Swizzle。如果 API 可以保留相同而无需 Swizzle,那么就请不要进行 Swizzle。
总共 50 行代码用于 userInfo
pod 'SHObjectUserInfo'
将此放在特定类或项目前缀文件中
#import "NSObject+SHObjectUserInfo.h"
或者
#import "SHObjectUserInfo.h"
myObjectThatInheritedFromNSObject.sh_userInfo = [@{@"myKey" : mYValue} mutableCopy];
如果您正在使用 SHSegueBlocks
[self SH_performSegueWithIdentifier:@"unwinder" withUserInfo:@{@"date" : [NSDate date]}];
在 destinationViewController 中
self.myDate = self.SH_userInfo[@"date"];
或者
[self SH_performSegueWithIdentifier:@"push"
andDestionationViewController:^(UIViewController * theDestinationViewController) {
theDestinationViewController.SH_userInfo = myDictionary
}];
如果您在项目中使用了 SHObjectUserInfo,我很乐意听到您的反馈。
电子邮件:[email protected]
推特:@seivanheidari
SHObjectUserInfo 根据 © 2013 Seivan 的要求制作,可在 MIT 许可证下免费分发。请参阅 LICENSE.md
文件。