Skip to content

Commit

Permalink
Rename value type
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 committed Jun 25, 2024
1 parent b6c3103 commit 47cfd3a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
44 changes: 22 additions & 22 deletions Sources/KSCrashRecording/KSCrashReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

@implementation KSCrashReport

- (instancetype) initWithReportType:(KSCrashReportType) reportType
dictionaryValue:(nullable NSDictionary<NSString*, id>*) dictionaryValue
stringValue:(nullable NSString*) stringValue
dataValue:(nullable NSData*) dataValue
- (instancetype) initWithValueType:(KSCrashReportValueType) valueType
dictionaryValue:(nullable NSDictionary<NSString*, id>*) dictionaryValue
stringValue:(nullable NSString*) stringValue
dataValue:(nullable NSData*) dataValue
{
self = [super init];
if(self != nil)
{
_reportType = reportType;
_valueType = valueType;
_dictionaryValue = [dictionaryValue copy];
_stringValue = [stringValue copy];
_dataValue = [dataValue copy];
Expand All @@ -46,26 +46,26 @@ - (instancetype) initWithReportType:(KSCrashReportType) reportType

+ (instancetype) reportWithDictionary:(NSDictionary<NSString*, id>*) dictionaryValue
{
return [[KSCrashReport alloc] initWithReportType:KSCrashReportTypeDictionary
dictionaryValue:dictionaryValue
stringValue:nil
dataValue:nil];
return [[KSCrashReport alloc] initWithValueType:KSCrashReportValueTypeDictionary
dictionaryValue:dictionaryValue
stringValue:nil
dataValue:nil];
}

+ (instancetype) reportWithString:(NSString*) stringValue
{
return [[KSCrashReport alloc] initWithReportType:KSCrashReportTypeString
dictionaryValue:nil
stringValue:stringValue
dataValue:nil];
return [[KSCrashReport alloc] initWithValueType:KSCrashReportValueTypeString
dictionaryValue:nil
stringValue:stringValue
dataValue:nil];
}

+ (instancetype) reportWithData:(NSData*) dataValue
{
return [[KSCrashReport alloc] initWithReportType:KSCrashReportTypeData
dictionaryValue:nil
stringValue:nil
dataValue:dataValue];
return [[KSCrashReport alloc] initWithValueType:KSCrashReportValueTypeData
dictionaryValue:nil
stringValue:nil
dataValue:dataValue];
}

- (BOOL) isEqual:(id) object
Expand All @@ -76,7 +76,7 @@ - (BOOL) isEqual:(id) object
}
KSCrashReport *other = object;
#define SAME_OR_EQUAL(GETTER) ((self.GETTER) == (other.GETTER) || [(self.GETTER) isEqual:(other.GETTER)])
return self.reportType == other.reportType
return self.valueType == other.valueType
&& SAME_OR_EQUAL(stringValue)
&& SAME_OR_EQUAL(dictionaryValue)
&& SAME_OR_EQUAL(dataValue);
Expand All @@ -85,13 +85,13 @@ - (BOOL) isEqual:(id) object

- (NSString*) description
{
switch(self.reportType)
switch(self.valueType)
{
case KSCrashReportTypeDictionary:
case KSCrashReportValueTypeDictionary:
return [self.dictionaryValue description];
case KSCrashReportTypeString:
case KSCrashReportValueTypeString:
return [self.stringValue description];
case KSCrashReportTypeData:
case KSCrashReportValueTypeData:
return [self.dataValue description];
}
}
Expand Down
22 changes: 11 additions & 11 deletions Sources/KSCrashRecording/include/KSCrashReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, KSCrashReportType) {
KSCrashReportTypeDictionary,
KSCrashReportTypeString,
KSCrashReportTypeData,
};
typedef NS_ENUM(NSUInteger, KSCrashReportValueType) {
KSCrashReportValueTypeDictionary,
KSCrashReportValueTypeString,
KSCrashReportValueTypeData,
} NS_SWIFT_NAME(CrashReportValueType);

/**
* A class that represent a recorded crash report.
Expand All @@ -42,9 +42,9 @@ NS_SWIFT_NAME(CrashReport)
@interface KSCrashReport : NSObject

/**
* This report type defines which one of the value properties below is populated.
* The type of the value of this crash report (dictionary, string, data)
*/
@property (nonatomic, readonly, assign) KSCrashReportType reportType;
@property (nonatomic, readonly, assign) KSCrashReportValueType valueType;

/**
* A structured dictionary version of crash report.
Expand All @@ -66,10 +66,10 @@ NS_SWIFT_NAME(CrashReport)
- (instancetype) init NS_UNAVAILABLE;
+ (instancetype) new NS_UNAVAILABLE;

- (instancetype) initWithReportType:(KSCrashReportType) reportType
dictionaryValue:(nullable NSDictionary<NSString*, id>*) dictionaryValue
stringValue:(nullable NSString*) stringValue
dataValue:(nullable NSData*) dataValue NS_DESIGNATED_INITIALIZER;
- (instancetype) initWithValueType:(KSCrashReportValueType) valueType
dictionaryValue:(nullable NSDictionary<NSString*, id>*) dictionaryValue
stringValue:(nullable NSString*) stringValue
dataValue:(nullable NSData*) dataValue NS_DESIGNATED_INITIALIZER;

+ (instancetype) reportWithDictionary:(NSDictionary<NSString*, id>*) dictionaryValue;
+ (instancetype) reportWithString:(NSString*) stringValue;
Expand Down

0 comments on commit 47cfd3a

Please sign in to comment.