在查看Github 存储库并查看BugsnagMetaData
版本之间的差异后,我找到了恢复此功能的方法。我写了一个扩展类的类别:
@interface BugsnagMetaData (BugsnagExtension)
- (void)mergeWith:(NSDictionary *)data;
@end
@implementation BugsnagMetaData (BugsnagExtension)
- (void)mergeWith:(NSDictionary *)data {
@synchronized(self) {
NSString *customDataKey = @"customData";
[data enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
NSMutableDictionary *destination = [self getTab:customDataKey];
if ([value isKindOfClass:[NSDictionary class]]) {
NSDictionary *source = value;
[source enumerateKeysAndObjectsUsingBlock:^(id sourceKey, id sourceValue, BOOL *stop) {
if ([destination objectForKey:sourceKey] && [sourceValue isKindOfClass:[NSDictionary class]]) {
[[destination objectForKey:sourceKey] mergeWith:(NSDictionary *)sourceValue];
} else {
[destination setObject:sourceValue forKey:sourceKey];
}
}];
} else {
[destination setObject:value forKey:key];
}
}];
[self.delegate metaDataChanged:self];
}
}
@end
此函数能够像以前一样接受包含 NSDictionary 的 NSDictionary,并且[self.delegate metaDataChanged:self]
仅在需要时才有效调用。