Where to transform data, NSViewController or NSArrayController?

97 Views Asked by At

I'm confused about where the transformation of data from Core Data to an NSView subclass takes place.

After reading Apple's Cocoa Bindings Programming Topics they seem to suggest making that transformation happen in NSArrayController.

enter image description here

But, then I read their Bindings Message Flow section, and it implies in step 10 that transformations take place in an NSViewController subclass.

enter image description here

I've also heard that NSArrayController, or anything from NSController shouldn't be subclassed. But, then I read from this StackOverflow that NSController and its subclasses are meant to be subclassed whenever you have a different form of data going out than coming in to an NSView.

So, which is it?

My Application

I've designed a candlestick graph that takes a number of objects from a custom class Candle to represent the CAShapeLayer and other properties.

To me, this is a perfect place for NSArrayController to manage all the Candle objects I have for any particular candlestick graph NSView.

Some of my data, I need to transform from price Float values to pixel CGFloat values. There's some geometry and math that I'm doing to get that.

Obviously, NSArrayController will handle the Candle objects, but does the data transformation happen in NSViewController or NSArrayController?

0

There are 0 best solutions below