Skip to content

Commit c00a9eb

Browse files
committed
Turned on the standard Core Plot warnings in the DatePlot example app and fixed the resulting warnings.
1 parent cdfb04f commit c00a9eb

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

‎examples/DatePlot/Controller.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#import <Cocoa/Cocoa.h>
22
#import <CorePlot/CorePlot.h>
33

4-
@interface Controller : NSObject<CPTPlotDataSource> {
5-
IBOutlet CPTGraphHostingView *hostView;
6-
CPTXYGraph *graph;
7-
NSArray *plotData;
8-
}
4+
@interface Controller : NSObject<CPTPlotDataSource>
95

106
@end

‎examples/DatePlot/Controller.m‎

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
#import "Controller.h"
22
#import <CorePlot/CorePlot.h>
33

4+
@interface Controller()
5+
6+
@property (nonatomic, readwrite, strong) IBOutlet CPTGraphHostingView *hostView;
7+
@property (nonatomic, readwrite, strong) CPTXYGraph *graph;
8+
@property (nonatomic, readwrite, strong) NSArray *plotData;
9+
10+
@end
11+
12+
#pragma mark -
13+
414
@implementation Controller
515

16+
@synthesize hostView;
17+
@synthesize graph;
18+
@synthesize plotData;
19+
620
-(void)awakeFromNib
721
{
822
[super awakeFromNib];
@@ -15,21 +29,23 @@ -(void)awakeFromNib
1529
NSTimeInterval oneDay = 24 * 60 * 60;
1630

1731
// Create graph from theme
18-
graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
19-
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
20-
[graph applyTheme:theme];
21-
hostView.hostedGraph = graph;
32+
CPTXYGraph *newGraph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
33+
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
34+
[newGraph applyTheme:theme];
35+
self.graph = newGraph;
36+
37+
self.hostView.hostedGraph = newGraph;
2238

2339
// Setup scatter plot space
24-
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
40+
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)newGraph.defaultPlotSpace;
2541
NSTimeInterval xLow = 0.0;
2642
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(xLow) length:CPTDecimalFromDouble(oneDay * 5.0)];
2743
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromDouble(1.0) length:CPTDecimalFromDouble(3.0)];
2844

2945
// Axes
30-
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)graph.axisSet;
46+
CPTXYAxisSet *axisSet = (CPTXYAxisSet *)newGraph.axisSet;
3147
CPTXYAxis *x = axisSet.xAxis;
32-
x.majorIntervalLength = CPTDecimalFromFloat(oneDay);
48+
x.majorIntervalLength = CPTDecimalFromDouble(oneDay);
3349
x.orthogonalCoordinateDecimal = CPTDecimalFromDouble(2.0);
3450
x.minorTicksPerInterval = 0;
3551
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
@@ -41,7 +57,7 @@ -(void)awakeFromNib
4157
CPTXYAxis *y = axisSet.yAxis;
4258
y.majorIntervalLength = CPTDecimalFromDouble(0.5);
4359
y.minorTicksPerInterval = 5;
44-
y.orthogonalCoordinateDecimal = CPTDecimalFromFloat(oneDay);
60+
y.orthogonalCoordinateDecimal = CPTDecimalFromDouble(oneDay);
4561

4662
// Create a plot that uses the data source method
4763
CPTScatterPlot *dataSourceLinePlot = [[CPTScatterPlot alloc] init];
@@ -53,32 +69,32 @@ -(void)awakeFromNib
5369
dataSourceLinePlot.dataLineStyle = lineStyle;
5470

5571
dataSourceLinePlot.dataSource = self;
56-
[graph addPlot:dataSourceLinePlot];
72+
[newGraph addPlot:dataSourceLinePlot];
5773

5874
// Add some data
5975
NSMutableArray *newData = [NSMutableArray array];
6076
for ( NSUInteger i = 0; i < 5; i++ ) {
61-
NSTimeInterval x = oneDay * i;
62-
NSNumber *y = @(1.2 * rand() / (double)RAND_MAX + 1.2);
77+
NSTimeInterval xVal = oneDay * i;
78+
double yVal = 1.2 * rand() / (double)RAND_MAX + 1.2;
6379
[newData addObject:
64-
@{ @(CPTScatterPlotFieldX): @(x),
65-
@(CPTScatterPlotFieldY): y }
80+
@{ @(CPTScatterPlotFieldX): @(xVal),
81+
@(CPTScatterPlotFieldY): @(yVal) }
6682
];
6783
}
68-
plotData = newData;
84+
self.plotData = newData;
6985
}
7086

7187
#pragma mark -
7288
#pragma mark Plot Data Source Methods
7389

7490
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
7591
{
76-
return plotData.count;
92+
return self.plotData.count;
7793
}
7894

7995
-(id)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
8096
{
81-
return plotData[index][@(fieldEnum)];
97+
return self.plotData[index][@(fieldEnum)];
8298
}
8399

84100
@end

‎examples/DatePlot/DatePlot.xcodeproj/project.pbxproj‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
90AF4F430F36CF1800753D26 /* DatePlot.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DatePlot.xib; sourceTree = "<group>"; };
7575
BC8E737C0FC0B3CF00DF8511 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
7676
BCB3FD510FD85658008875A4 /* CorePlotIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = CorePlotIcon.icns; sourceTree = "<group>"; };
77+
C3D6210B19DF70DB00652CE7 /* CorePlotWarnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = CorePlotWarnings.xcconfig; path = ../../framework/CorePlotWarnings.xcconfig; sourceTree = "<group>"; };
7778
/* End PBXFileReference section */
7879

7980
/* Begin PBXFrameworksBuildPhase section */
@@ -94,7 +95,7 @@
9495
isa = PBXGroup;
9596
children = (
9697
076184C10F3CAD5900A89A76 /* CorePlot.framework */,
97-
07E0DF80109C4E9500F108D2 /* UnitTests.octest */,
98+
07E0DF80109C4E9500F108D2 /* UnitTests.xctest */,
9899
);
99100
name = Products;
100101
sourceTree = "<group>";
@@ -158,6 +159,7 @@
158159
children = (
159160
32CA4F630368D1EE00C91783 /* DatePlot_Prefix.pch */,
160161
29B97316FDCFA39411CA2CEA /* main.m */,
162+
C3D6210B19DF70DB00652CE7 /* CorePlotWarnings.xcconfig */,
161163
);
162164
name = "Other Sources";
163165
sourceTree = "<group>";
@@ -247,7 +249,7 @@
247249
remoteRef = 076184C00F3CAD5900A89A76 /* PBXContainerItemProxy */;
248250
sourceTree = BUILT_PRODUCTS_DIR;
249251
};
250-
07E0DF80109C4E9500F108D2 /* UnitTests.octest */ = {
252+
07E0DF80109C4E9500F108D2 /* UnitTests.xctest */ = {
251253
isa = PBXReferenceProxy;
252254
fileType = wrapper.cfbundle;
253255
path = UnitTests.xctest;
@@ -341,6 +343,7 @@
341343
};
342344
C01FCF4F08A954540054247B /* Debug */ = {
343345
isa = XCBuildConfiguration;
346+
baseConfigurationReference = C3D6210B19DF70DB00652CE7 /* CorePlotWarnings.xcconfig */;
344347
buildSettings = {
345348
FRAMEWORK_SEARCH_PATHS = "";
346349
GCC_C_LANGUAGE_STANDARD = c99;
@@ -357,6 +360,7 @@
357360
};
358361
C01FCF5008A954540054247B /* Release */ = {
359362
isa = XCBuildConfiguration;
363+
baseConfigurationReference = C3D6210B19DF70DB00652CE7 /* CorePlotWarnings.xcconfig */;
360364
buildSettings = {
361365
FRAMEWORK_SEARCH_PATHS = "";
362366
GCC_C_LANGUAGE_STANDARD = c99;

0 commit comments

Comments
 (0)