Please note, this blog entry is from a previous course. You might want to check out the current one.
Your graphing UIView must be generic and reusable (i.e. it should be a generic x-y graphing class and know nothing about a CalculatorBrain). Use a protocol to get the graphing view’s data because Views should not own their data.
Basically we need a way to calculate an y value for a given x value, and to know where we want to place the graph and the size of the graph, which we define as protocol:
@protocol GraphViewDataSource - (id)calculateYValueFromXValue:(double)xValue; // NSNumber or string with error @property (nonatomic) CGFloat scale; // 1 = 100% @property (nonatomic) CGPoint origin; // point to place in the middle of the screen @end ... @property (nonatomic, weak) IBOutlet id <GraphViewDataSource> dataSource; ....
Continue reading “Assignment #3 Task #6”













