Assignment #3 Extra Task #2

Please note, this blog entry is from a previous course. You might want to check out the current one.

If you do Extra Credit #1, you’ll notice that some functions (like sin(x)) look so much nicer using the “line to” strategy (at least when zoomed in appropriately). Try dragging a UISwitch into your user-interface which lets the user switch back and forth between “dot mode” and “line to” mode drawing.

Add a new property to our graph view protocol:

@property (nonatomic) BOOL drawDots; // YES: draw dots; NO: draw lines

add adjust the drawRect: function accordingly:

if (self.dataSource.drawDots) {                        
  // draw dots
} else {
  // draw lines

In storyboard drag out and UISwitch into the calculator view controller, label it and connect it to an outlet, e.g.:

@property (weak, nonatomic) IBOutlet UISwitch *drawLinesSwitch;

Implement the missing protocol property in the graph view controller

@property (nonatomic) BOOL drawDots;
@synthesize drawDots = _drawDots;

and set it in prepareForSegue

[segue.destinationViewController setDrawDots:!self.drawLinesSwitch.on];

and graphButtonPressed

[gVC setDrawDots:!self.drawLinesSwitch.on];

Leave a Reply

Your email address will not be published.