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

Commit a43ba93

Browse files
author
Sam Spencer
committed
Nullability & Deprecation
Added nullability features available in Xcode 6.3. Added warnings to methods which will be deprecated in the next major release. Removed compile-time module check, because modules should now be the default.
1 parent bf9a97f commit a43ba93

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Classes/BEMSimpleLineGraphView.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@
77
// Copyright (c) 2014 Sam Spencer.
88
//
99

10-
#if __has_feature(objc_modules)
11-
// We recommend enabling Objective-C Modules in your project Build Settings for numerous benefits over regular #imports. Read more from the Modules documentation: http://clang.llvm.org/docs/Modules.html
1210
@import Foundation;
1311
@import UIKit;
1412
@import CoreGraphics;
15-
#else
16-
#import <Foundation/Foundation.h>
17-
#import <UIKit/UIKit.h>
18-
#import <CoreGraphics/CoreGraphics.h>
19-
#endif
2013

2114
#import "BEMCircle.h"
2215
#import "BEMLine.h"
@@ -30,6 +23,9 @@
3023

3124
extern const CGFloat BEMNullGraphValue;
3225

26+
// Tell the compiler to assume that no method should have a NULL value
27+
NS_ASSUME_NONNULL_BEGIN
28+
3329
/// Simple line graph / chart UIView subclass for iOS apps. Creates beautiful line graphs (without huge memory impacts) using QuartzCore.
3430
IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDelegate>
3531

@@ -44,7 +40,7 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
4440
4541
@abstract The BEMSimpleLineGraphView delegate object plays a key role in changing the appearance of the graph and receiving graph events. Use the delegate to provide appearance changes, receive touch events, and receive graph events. The delegate can be set from the interface or from code.
4642
@discussion The delegate must adopt the \p BEMSimpleLineGraphDelegate protocol. The delegate is not retained.*/
47-
@property (nonatomic, weak) IBOutlet id <BEMSimpleLineGraphDelegate> delegate;
43+
@property (nonatomic, weak, nullable) IBOutlet id <BEMSimpleLineGraphDelegate> delegate;
4844

4945

5046

@@ -123,17 +119,17 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
123119

124120
/** All the displayed values of the X-Axis.
125121
@return An array of NSStrings, one for each displayed X-Axis label. The array is sorted from the left side of the graph to the right side. */
126-
- (NSArray *)graphValuesForXAxis;
122+
- (nullable NSArray *)graphValuesForXAxis;
127123

128124

129125
/** All the data points on the graph.
130126
@return An array of NSNumbers, one for each data point. The array is sorted from the left side of the graph to the right side. */
131-
- (NSArray *)graphValuesForDataPoints;
127+
- (nullable NSArray *)graphValuesForDataPoints;
132128

133129

134130
/** All the labels of the X-Axis.
135131
@return An array of UILabels, one for each displayed X-Axis label. The array is sorted from the left side of the graph to the right side. */
136-
- (NSArray *)graphLabelsForXAxis;
132+
- (nullable NSArray *)graphLabelsForXAxis;
137133

138134

139135

@@ -143,7 +139,7 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
143139

144140

145141
/// The graph's label font used on various axis. This property may be privately overwritten, do not expect full functionality from this property.
146-
@property (strong, nonatomic) UIFont *labelFont;
142+
@property (strong, nonatomic, nullable) UIFont *labelFont;
147143

148144

149145
/// Time of the animation when the graph appears in seconds. Default value is 1.5.
@@ -396,7 +392,7 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
396392
@discussion The number of strings to be returned should be equal to the number of points in the graph (returned in \p numberOfPointsInLineGraph). Otherwise, an exception may be thrown.
397393
@param graph The graph object which is requesting the label on the specified X-Axis position.
398394
@param index The index from left to right of a given label on the X-axis. Is the same index as the one for the points. The first value for the index is 0. */
399-
- (NSString *)lineGraph:(BEMSimpleLineGraphView *)graph labelOnXAxisForIndex:(NSInteger)index;
395+
- (nullable NSString *)lineGraph:(nonnull BEMSimpleLineGraphView *)graph labelOnXAxisForIndex:(NSInteger)index;
400396

401397

402398
@end
@@ -598,46 +594,51 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
598594

599595

600596
/** \b DEPRECATED. Use \p numberOfPointsInLineGraph: instead. The number of points along the X-axis of the graph.
597+
@warning This method will be removed in the next version with breaking changes.
601598
@deprecated Deprecated in 1.3. Use \p numberOfPointsInLineGraph: instead.
602599
@return Number of points. */
603600
- (int)numberOfPointsInGraph __deprecated;
604601

605602

606603
/** \b DEPRECATED. Use \p lineGraph:valueForPointAtIndex: instead.
604+
@warning This method will be removed in the next version with breaking changes.
607605
@deprecated Deprecated in 1.3. Use \p lineGraph:valueForPointAtIndex: instead.
608606
@param index The index from left to right of a given point (X-axis). The first value for the index is 0.
609607
@return The Y-axis value at a given index. */
610608
- (float)valueForIndex:(NSInteger)index __deprecated;
611609

612610

613611
/** \b DEPRECATED. Use \p lineGraph:didTouchGraphWithClosestIndex: instead. Gets called when the user starts touching the graph. The property 'enableTouchReport' must be set to YES.
612+
@warning This method will be removed in the next version with breaking changes.
614613
@deprecated Deprecated in 1.3. Use \p lineGraph:didTouchGraphWithClosestIndex: instead.
615614
@param index The closest index (X-axis) from the location the user is currently touching. */
616615
- (void)didTouchGraphWithClosestIndex:(int)index __deprecated;
617616

618617

619618
/** \b DEPRECATED. Use \p lineGraph:didReleaseTouchFromGraphWithClosestIndex: instead. Gets called when the user stops touching the graph.
619+
@warning This method will be removed in the next version with breaking changes.
620620
@deprecated Deprecated in 1.3. Use \p lineGraph:didReleaseTouchFromGraphWithClosestIndex: instead.
621621
@param index The closest index (X-axis) from the location the user last touched. */
622622
- (void)didReleaseGraphWithClosestIndex:(float)index __deprecated;
623623

624624

625625
/** \b DEPRECATED. Use \p numberOfGapsBetweenLabelsOnLineGraph: instead. The number of free space between labels on the X-axis to avoid overlapping.
626+
@warning This method will be removed in the next version with breaking changes.
626627
@deprecated Deprecated in 1.3. Use \p numberOfGapsBetweenLabelsOnLineGraph: instead.
627628
@discussion For example returning '1' would mean that half of the labels on the X-axis are not displayed: the first is not displayed, the second is, the third is not etc. Returning '0' would mean that all of the labels will be displayed. Finally, returning a value equal to the number of labels will only display the first and last label.
628629
@return The number of labels to "jump" between each displayed label on the X-axis. */
629630
- (int)numberOfGapsBetweenLabels __deprecated;
630631

631632

632633
/** \b DEPRECATED. Use \p lineGraph:labelOnXAxisForIndex: instead. The string to display on the label on the X-axis at a given index. Please note that the number of strings to be returned should be equal to the number of points in the Graph.
634+
@warning This method will be removed in the next version with breaking changes.
633635
@deprecated Deprecated in 1.3. Use \p lineGraph:labelOnXAxisForIndex: instead.
634636
@param index The index from left to right of a given label on the X-axis. Is the same index as the one for the points. The first value for the index is 0. */
635637
- (NSString *)labelOnXAxisForIndex:(NSInteger)index __deprecated;
636638

637639

638640
/** \b DEPRECATED. No longer available on \p BEMSimpleLineGraphDelegate. Implement this method on \p BEMSimpleLineGraphDataSource instead. The number of points along the X-axis of the graph.
639641
@deprecated Deprecated in 2.3. Implement with \p BEMSimpleLineGraphDataSource instead.
640-
641642
@param graph The graph object requesting the total number of points.
642643
@return The total number of points in the line graph. */
643644
- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph __unavailable __deprecated;
@@ -660,4 +661,6 @@ IB_DESIGNABLE @interface BEMSimpleLineGraphView : UIView <UIGestureRecognizerDel
660661
- (NSString *)lineGraph:(BEMSimpleLineGraphView *)graph labelOnXAxisForIndex:(NSInteger)index __unavailable __deprecated;
661662

662663

664+
NS_ASSUME_NONNULL_END
665+
663666
@end

0 commit comments

Comments
 (0)