shobhitmehrotra1 / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

CPTGraphHostingView's commonInit clobbers hostedGraph instance variable #555

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Make a subclass of CPTGraphHostingView on iOS
2. In the init, configure a graph and set the hosted graph.  Add a delegate to 
get called on taps
3. graph is displayed, taps don't work
4. look at touchesBegan in CPTGraphHostingView, the hostedGraph is now nil

What is the expected output? What do you see instead?

hostedGraph doesn't get clobbered after I set it.

What version of the product are you using? On what operating system?

CorePlot 1.3, iOS

Please provide any additional information below.

What's happening is -commonInit is being called at awakeFromNib time, and it 
clobbers hostedGraph (which seems unnecessary because instance variables are 
automatically nil'd out anyway - that's +alloc's contract).

There's this comment:

// On iOS, the init method is not called when loading from a XIB

Instead, you should use initWithCoder which calls commonInit.  that way I can 
set a hosted graph.

it's kind of a hassle now.  I can't override awakeFromNib because 
CPTGraphHostingView's awakeFromNib is called after my subclass, threby 
clobbering hostedGraph.  -commonInit isn't exposed in the header (which is 
fine), but I can't override it and sendsuper first because there's no visible 
superclass method, so I need to create a category to keep the compiler happy.  
I'll probably just add a "ok view you're now loaded, go set your hostedGraph 
again"

Original issue reported on code.google.com by ma...@badgertronics.com on 29 Jul 2013 at 10:02

GoogleCodeExporter commented 8 years ago
CPTGraphHostingView is a *view*. Why are you making it a graph controller, too? 
I think mixing roles is what is causing the problem.

Original comment by eskr...@mac.com on 30 Jul 2013 at 12:06

GoogleCodeExporter commented 8 years ago
I've got a number of independent self-contained graphs that can be positioned 
around a canvas (like a status kiosk).  Views are kind of nice for that, and 
keeps much of the complexity out of a giant controller, or introducing a bunch 
of little classes that just move data around.

Doesn't change the fact that there is a way on iOS to participate in the 
initialization pipeline (-initWithCoder) and not pollute awakeWithNib.

Original comment by ma...@badgertronics.com on 30 Jul 2013 at 12:10

GoogleCodeExporter commented 8 years ago
This issue was closed by revision f52e0a0a497c.

Original comment by eskr...@mac.com on 30 Jul 2013 at 12:33

GoogleCodeExporter commented 8 years ago
Woo! Thank you!!

Original comment by ma...@badgertronics.com on 30 Jul 2013 at 12:59