Application crashes when working with core plot
Asked Answered
R

2

5
Unknown class CPTGraphHostingView in Interface Builder file.
2012-01-09 16:09:34.242 ChartArea[2595:207] -[UIView setHostedGraph:]: unrecognized selector sent to instance 0x4c064f0
2012-01-09 16:09:34.245 ChartArea[2595:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setHostedGraph:]: unrecognized selector sent to instance 0x4c064f0'

This is the error I am getting this evening. i am setting the class name of to CPTGraphHostingView to my uiview within interfacebuilder.

Ralli answered 9/1, 2012 at 10:42 Comment(3)
try this in your code CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view;Taiga
CPTGraphHostingView *hostingView = (CPTGraphHostingView *)self.view; this is what i used in my code!Ralli
its about the interface builder which is not reading. Saying unknow class its the problem even i given proper the class in my interface Builder for the UIView to get the Bar chart graphRalli
E
16

I had the same problem and this worked for me:

Select your project from the navigator panel in Xcode and then highlight the Build Settings tab. Filter the settings or locate ‘Other Linker Flags’ from this list and then add -ObjC -all_load to these settings

(From here: http://www.johnwordsworth.com/2011/10/adding-charts-to-your-iphone-ipad-app-using-core-plot/)

Elegiac answered 18/1, 2012 at 17:3 Comment(2)
Typical case of 'RTFM'. I was wondering what those linker flags were for...the documentation of CorePlot really is the pits...ah well.Rufena
@kiran, this answer should be approved.Damien
Q
1

It is possible that your view in ViewController is not a type of CPTGraphHostingView, so the view fails to cast.

It can fixed by creating exact instance of CPTGraphHostingView then add it to the ViewController's view.

CGRect frame = [[self view] bounds];

CPTGraphHostingView* graphHost = [[CPTGraphHostingView alloc] initWithFrame:frame];

[[self view] addSubview: graphHost];

Hope this help.

Quinine answered 5/2, 2013 at 14:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.