Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMike Zhu
1,840 PointsCrash when using Core Plot Library in iOS
Basically, I encounter a crash when using the Core Plot. According to the tutorial (https://github.com/core-plot/core-plot/wiki/Using-Core-Plot-in-an-Application) about how to install the CorePlot static library, I just drag the CorePlotHeaders file and the libCorePlot-CocoaTouch.a into my project. Then I add the QuartzCore and Accelerate framework. Then I have changed the "Other Linker Flags" to "-Objc" and "-all_load".
I have written this code:
- (void) configLineGraph
{
CGRect graphFrame = CGRectMake(0, 0, self.graphView.frame.size.width, self.graphView.frame.size.height);
// The graph should be put into a hosting view
CPTGraphHostingView *hostingView = [[CPTGraphHostingView alloc]init];
[hostingView setFrame:graphFrame];
// Add it to the view
[self.graphView addSubview:hostingView];
// Draw with CPTGraph
// This is a line graph
CPTXYGraph *graph = [[CPTXYGraph alloc]init];
[graph setFrame:hostingView.frame];
// Add the graph to the hosting view
[hostingView setHostedGraph:graph];
// Draw the scatter plot
CPTScatterPlot *scatterPlot = [[CPTScatterPlot alloc]init];
[scatterPlot setFrame:graph.bounds];
// Add the scatter plot to graph
[graph addPlot:scatterPlot];
[scatterPlot setDataSource:self];
// Setup the plot space
// Location is the initial value
// Length is the range
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *) scatterPlot.plotSpace;
[plotSpace setXRange:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat([voltageDataArray count] - 1)]];
[plotSpace setYRange:[CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0) length:CPTDecimalFromFloat(1.55)]];
}
However, when I run my project, it crashes with the message:
2015-07-02 16:59:44.435 Ansmann[4952:236111] -[CPTTextStyle attributes]: unrecognized selector sent to instance 0x7f97a1e26a90
2015-07-02 16:59:44.439 Ansmann[4952:236111] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTTextStyle attributes]: unrecognized selector sent to instance 0x7f97a1e26a90'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ac8dc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010a56abb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010ac950ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010abeb13c ___forwarding___ + 988
4 CoreFoundation 0x000000010abeacd8 _CF_forwarding_prep_0 + 120
5 Ansmann 0x0000000109ce7d7b -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 1259
6 Ansmann 0x0000000109ce93b1 -[CPTAxis relabel] + 1457
7 Ansmann 0x0000000109ceac7b -[CPTAxis layoutSublayers] + 75
8 QuartzCore 0x0000000109f536d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
9 QuartzCore 0x0000000109f53546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
10 QuartzCore 0x0000000109ebf886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
11 QuartzCore 0x0000000109ec0a3a _ZN2CA11Transaction6commitEv + 462
12 UIKit 0x000000010b2c6a2d -[UIApplication _reportMainSceneUpdateFinished:] + 44
13 UIKit 0x000000010b2c76f1 -[UIApplication _runWithMainScene:transitionContext:completion:] + 2648
14 UIKit 0x000000010b2c60d5 -[UIApplication workspaceDidEndTransaction:] + 179
15 FrontBoardServices 0x00000001101bf5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
16 CoreFoundation 0x000000010abc141c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
17 CoreFoundation 0x000000010abb7165 __CFRunLoopDoBlocks + 341
18 CoreFoundation 0x000000010abb6f25 __CFRunLoopRun + 2389
19 CoreFoundation 0x000000010abb6366 CFRunLoopRunSpecific + 470
20 UIKit 0x000000010b2c5b42 -[UIApplication _run] + 413
21 UIKit 0x000000010b2c8900 UIApplicationMain + 1282
22 Ansmann 0x0000000109c95e7f main + 111
23 libdyld.dylib 0x000000010cdda145 start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException