Skip to content

Commit

Permalink
Merge pull request #228 from WideSpectrumComputing/master
Browse files Browse the repository at this point in the history
release candidate: v1.11.2
  • Loading branch information
akornich authored Jan 7, 2020
2 parents dd1e014 + 6bdda93 commit d615bc3
Show file tree
Hide file tree
Showing 30 changed files with 311 additions and 135 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co

## Release Notes

**1.11.2**
- chore: resolve #227: Fix build warnings.

**1.11.1**
- fix: resolve #225: Fix cocopods' podspec

Expand Down
2 changes: 1 addition & 1 deletion Rollbar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|

s.version = "1.11.1"
s.version = "1.11.2"
s.name = "Rollbar"
s.summary = "Objective-C library for crash reporting and logging with Rollbar. It works on iOS and macOS."
s.description = <<-DESC
Expand Down
4 changes: 2 additions & 2 deletions Rollbar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4271,7 +4271,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.11.1;
CURRENT_PROJECT_VERSION = 1.11.2;
DEVELOPMENT_TEAM = LDX6L68VZJ;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down Expand Up @@ -4332,7 +4332,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 1.11.1;
CURRENT_PROJECT_VERSION = 1.11.2;
DEVELOPMENT_TEAM = LDX6L68VZJ;
ENABLE_BITCODE = YES;
ENABLE_NS_ASSERTIONS = NO;
Expand Down
7 changes: 3 additions & 4 deletions Rollbar/DTOs/DataTransferObject+Protected.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ NS_ASSUME_NONNULL_BEGIN
/// Dfines the protected DTO interface
@interface DataTransferObject (Protected)

#pragma mark - Initializers
#pragma mark - Properties

- (instancetype)initWithJSONData:(NSData *)data;
- (instancetype)initWithDictionary:(NSDictionary *)data;
- (instancetype)initWithArray:(NSArray *)data;
@property (nonatomic, readonly, nullable) NSMutableDictionary *dataDictionary;
@property (nonatomic, readonly, nullable) NSMutableArray *dataArray;

#pragma mark - Core API: transferable data getter/setter by key

Expand Down
89 changes: 33 additions & 56 deletions Rollbar/DTOs/DataTransferObject+Protected.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,65 +10,42 @@

@implementation DataTransferObject (Protected)

#pragma mark - Initializers

- (instancetype)initWithJSONData: (NSData *)data {
self = [super init];
if (self) {
[self deserializeFromJSONData:data];
}
return self;
}

- (instancetype)initWithDictionary:(NSDictionary *)data; {

self = [super init];
if (self) {
if (!data) {
return self;
}
else if (![DataTransferObject isTransferableObject:data]) {
return self;
}
else {
if ([data isKindOfClass:[NSMutableDictionary class]]) {
self->_data = (NSMutableDictionary *)data;
}
else {
self->_data = data.mutableCopy;
}

for (NSString *key in self->_data.allKeys) {
if (self->_data[key] == [NSNull null]) {
[self->_data removeObjectForKey:key];
}
}
}
// else if ([data isKindOfClass:[NSMutableDictionary class]]) {
// self->_data = (NSMutableDictionary *) data;
// }
// else if ([data isKindOfClass:[NSDictionary class]]) {
// self->_data = [data mutableCopy];
// }
}
return self;
}
#pragma mark - Property overrides

- (instancetype)initWithArray:(NSArray *)data {
//TODO: implement...
return nil;
- (NSString *)description {
return [self serializeToJSONString];
}

- (instancetype)init {
@throw [NSException exceptionWithName:NSInternalInconsistencyException
reason:@"Must use one of initWith...: instead."
userInfo:nil];
}
#pragma mark - Properties

#pragma mark - Property overrides
-(NSMutableDictionary *)dataDictionary {
if (self->_dataDictionary) {
return self->_dataDictionary;
}
else {
if (!self->_data || self->_data == [NSNull null]) {
return self->_dataDictionary;
}
if (!self->_dataArray && [self->_data isKindOfClass:[NSDictionary class]]) {
self->_dataDictionary = (NSMutableDictionary *) self->_data;
}
return self->_dataDictionary;
}
}

- (NSString *)description {
return [self serializeToJSONString];
-(NSMutableArray *)dataArray {
if (self->_dataArray) {
return self->_dataArray;
}
else {
if (!self->_data || self->_data == [NSNull null]) {
return self->_dataArray;
}
if (!self->_dataDictionary && [self->_data isKindOfClass:[NSArray class]]) {
self->_dataArray = (NSMutableArray *) self->_data;
}
return self->_dataArray;
}
}

#pragma mark - Core API: transferable data getter/setter by key
Expand Down Expand Up @@ -118,8 +95,8 @@ - (DataTransferObject *)safelyGetDataTransferObjectByKey:(NSString *)key {
}

- (NSMutableDictionary *)safelyGetDictionaryByKey:(NSString *)key {
NSMutableDictionary *result = [self->_data objectForKey:key];
if (nil == result) {
NSMutableDictionary *result = [self->_dataDictionary objectForKey:key];
if (!result) {
result = [[NSMutableDictionary alloc] initWithCapacity:5];
[self->_data setObject:result forKey:key];
}
Expand Down
39 changes: 35 additions & 4 deletions Rollbar/DTOs/DataTransferObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,60 @@ NS_ASSUME_NONNULL_BEGIN

@interface DataTransferObject : NSObject <JSONSupport> {
@private
NSMutableDictionary *_data;
id _data;
//...

//@protected
//...

//@public
//...
@private
NSMutableDictionary *_dataDictionary;
NSMutableArray *_dataArray;
}

/// Checks if the provided object is transferrable (ie could be converted to/from JSON)
/// @param obj the object in question
+ (BOOL)isTransferableObject:(id)obj;

/// Checks if the provided object could be used as a DTO property/data value
/// @param obj the object in question
+ (BOOL)isTransferableDataValue:(id)obj;

/// Returns list of the property names of this DTO
- (NSArray *)getDefinedProperties;

/// Checks if the provided DTO has same defined properties as this instance
/// @param otherDTO the other DTO to compare with
- (BOOL)hasSameDefinedPropertiesAs:(DataTransferObject *)otherDTO;

/// Signifies that this DTO doesn't carry any useful data and is just an empty transpot "shell"
@property (nonatomic, readonly) BOOL isEmpty;

#pragma mark - initializers
#pragma mark - Initializers

/// Initialize this DTO instance with valid JSON data string seed
/// @param jsonString valid JSON data string seed
- (instancetype)initWithJSONString:(NSString *)jsonString;

/// Initialize this DTO instance with valid JSON NSData seed
/// @param data valid JSON NSData seed
- (instancetype)initWithJSONData:(NSData *)data;

/// Initialize this DTO instance with valid JSON NSDictionary seed
/// @param data valid JSON NSDictionary seed
- (instancetype)initWithDictionary:(NSDictionary *)data NS_DESIGNATED_INITIALIZER;

/// Initialize this DTO instance with valid JSON NSArray seed
/// @param data valid JSON NSArray seed
- (instancetype)initWithArray:(NSArray *)data NS_DESIGNATED_INITIALIZER;

/// Initialize empty DTO
- (instancetype)init NS_DESIGNATED_INITIALIZER;


/// @abstract use any of initWith... initializers instead of this one
//- (instancetype)init NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
Loading

0 comments on commit d615bc3

Please sign in to comment.