Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Spencer committed Aug 4, 2017
1 parent d7b5a0c commit 049c520
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
13 changes: 4 additions & 9 deletions Classes/BEMAverageLine.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ - (instancetype)init {
return self;
}

- (instancetype) initWithCoder:(NSCoder *)coder {

- (instancetype)initWithCoder:(NSCoder *)coder {
#define RestoreProperty(property, type) {\
if ([coder containsValueForKey:@#property]) { \
self.property = [coder decode ## type ##ForKey:@#property ]; \
Expand All @@ -32,7 +31,6 @@ - (instancetype) initWithCoder:(NSCoder *)coder {
self = [self init];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullable-to-nonnull-conversion"

RestoreProperty (enableAverageLine, Bool);
RestoreProperty (color, Object);
RestoreProperty (yValue, Double);
Expand All @@ -42,12 +40,10 @@ - (instancetype) initWithCoder:(NSCoder *)coder {
RestoreProperty (title, Object);
#pragma clang diagnostic pop

//AverageLine
return self;
}

- (void) encodeWithCoder: (NSCoder *)coder {

- (void)encodeWithCoder:(NSCoder *)coder {
#define EncodeProperty(property, type) [coder encode ## type: self.property forKey:@#property]
EncodeProperty (enableAverageLine, Bool);
EncodeProperty (color, Object);
Expand All @@ -58,8 +54,6 @@ - (void) encodeWithCoder: (NSCoder *)coder {
EncodeProperty (title, Object);
}



- (void)setLabel:(UILabel *)label {
if (_label != label) {
[_label removeFromSuperview];
Expand All @@ -68,6 +62,7 @@ - (void)setLabel:(UILabel *)label {
}

- (void)dealloc {
self.label= nil;
self.label = nil;
}

@end
9 changes: 4 additions & 5 deletions Classes/BEMSimpleLineGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ @implementation BEMSimpleLineGraphView

// MARK: - Initialization

- (instancetype) initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) [self commonInit];
return self;
}

- (instancetype) initWithCoder:(NSCoder *)coder {
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) [self commonInit];
[self restorePropertyWithCoder:coder];
Expand Down Expand Up @@ -202,7 +202,7 @@ - (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
[self encodePropertiesWithCoder:coder];
}

- (void)encodeWithCoder: (NSCoder *)coder {
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[self encodePropertiesWithCoder:coder];
}
Expand Down Expand Up @@ -515,7 +515,7 @@ - (CGFloat)labelWidthForValue:(CGFloat)value {
return [labelString sizeWithAttributes:attributes].width;
}

- (CGFloat) calculateWidestLabel {
- (CGFloat)calculateWidestLabel {
NSDictionary *attributes = @{NSFontAttributeName: self.labelFont};
CGFloat widestNumber;
if (self.autoScaleYAxis == YES){
Expand Down Expand Up @@ -570,7 +570,6 @@ - (BEMCircle *)circleDotAtIndex:(NSUInteger)index forValue:(CGFloat)dotValue reu
}

- (void)drawDots {

// Remove all data points before adding them to the array
[dataPoints removeAllObjects];

Expand Down
2 changes: 1 addition & 1 deletion Sample Project/SimpleLineChart.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@
C3B90A59187D15F7003E407D /* BEMCircle.m */,
C3B90A5A187D15F7003E407D /* BEMLine.h */,
C3B90A5B187D15F7003E407D /* BEMLine.m */,
A63990B41AD4923900B14D88 /* BEMAverageLine.m */,
A63990B31AD4923900B14D88 /* BEMAverageLine.h */,
A63990B41AD4923900B14D88 /* BEMAverageLine.m */,
A6AC89591C5882DD0052AB1C /* BEMGraphCalculator.h */,
A6AC895A1C5882DD0052AB1C /* BEMGraphCalculator.m */,
);
Expand Down

0 comments on commit 049c520

Please sign in to comment.