Skip to content

Commit

Permalink
Getter method and nonnull, nonatomic property
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicDraws committed Jan 29, 2016
1 parent 330c31f commit c861aea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/YOChartImageKit/YOBarChartImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef NS_ENUM(NSInteger, YOBarChartImageBarStyle){
* The maximum value to use for the chart. Setting this will override the
* default behavior of using the highest value as maxValue.
*/
@property NSNumber* maxValue;
@property (nonnull, nonatomic) NSNumber* maxValue;

/**
* The style of the bar chart.
Expand Down
4 changes: 4 additions & 0 deletions Source/YOChartImageKit/YOBarChartImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ - (instancetype)init
return self;
}

- (NSNumber *) maxValue {
return _maxValue ? _maxValue : [NSNumber numberWithFloat:[[_values valueForKeyPath:@"@max.floatValue"] floatValue]];
}

const CGFloat kBarPaddingMultipler = 20.0f;

- (UIImage *)drawImage:(CGRect)frame scale:(CGFloat)scale {
Expand Down
2 changes: 1 addition & 1 deletion Source/YOChartImageKit/YOLineChartImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* The maximum value to use for the chart. Setting this will override the
* default behavior of using the highest value as maxValue.
*/
@property NSNumber* maxValue;
@property (nonnull, nonatomic) NSNumber* maxValue;

/**
* The width of chart's stroke.
Expand Down
4 changes: 4 additions & 0 deletions Source/YOChartImageKit/YOLineChartImage.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ - (instancetype)init {
return self;
}

- (NSNumber *) maxValue {
return _maxValue ? _maxValue : [NSNumber numberWithFloat:[[_values valueForKeyPath:@"@max.floatValue"] floatValue]];
}

- (UIImage *)drawImage:(CGRect)frame scale:(CGFloat)scale {
NSAssert(_values.count > 0, @"YOLineChartImage // must assign values property which is an array of NSNumber");

Expand Down

0 comments on commit c861aea

Please sign in to comment.