-
-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ChartViewBase as the type and instantiating the chart later as a specific type #2338
Comments
Pass a property to your viewcontroller for which chart type you want and create it in code. |
second agree, use the base class in your xib and create sub classes in code. |
When I set the ChartViewBase object to a BarChartView type (myChart.chart = BarChartView() or myChart.chart = BarChartView(frame: myChart.chart.contentRect) ) it sets myChart.chart to nil. I don't know why it sets it to nil or what I'm doing wrong. Any ideas on how to get it so that it's not nil? Thanks, |
@pktrkts is your |
Yes it is. Is it not supposed to be? |
Okay removing the "weak" keyword made the problem go away. Thank you! |
you need to figure out why yourself, as this is a common mistake. |
Hi,
What I'm trying to do is cut down on the number of custom UIViews my codebase will have. I'm going to have either a bar graph, a line graph, or a pie chart in view controllers that are otherwise identical. I'm going to create at least one custom UIView (since there are several different kinds of things the charts will be displaying data for, I'll have 16 view controllers, but there seems to be no way around having so many view controllers without using a poor design). What I was wondering is, could I use ChartViewBase and then instantiate the type of graph later? This would save me from making three custom uiviews that are otherwise identical, aside from being different chart types (BarChartView, LineChartView, etc.) It would really be nice to know if this works before I spend an inordinate amount of time implementing it in the code. Thanks for your consideration of this matter.
Sincerely,
Sean
The text was updated successfully, but these errors were encountered: