Swiftgram/Classes/BITData.m
Christoph Wendt 56628bb824 Fix naming
2015-09-09 18:46:07 -07:00

40 lines
1.1 KiB
Objective-C

#import "BITData.h"
#import "BITOrderedDictionary.h"
/// Data contract class for type Data.
@implementation BITData
///
/// Adds all members of this class to a dictionary
/// @param dictionary to which the members of this class will be added.
///
- (BITOrderedDictionary *)serializeToDictionary {
BITOrderedDictionary *dict = [super serializeToDictionary];
BITOrderedDictionary *baseDataDict = [self.baseData serializeToDictionary];
if ([NSJSONSerialization isValidJSONObject:baseDataDict]) {
[dict setObject:baseDataDict forKey:@"baseData"];
} else {
NSLog(@"[HockeyApp] Some of the telemetry data was not NSJSONSerialization compatible and could not be serialized!");
}
return dict;
}
#pragma mark - NSCoding
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if(self) {
_baseData = [coder decodeObjectForKey:@"self.baseData"];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:self.baseData forKey:@"self.baseData"];
}
@end