Assignment #3 Task #6

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”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #5

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

To implement your new MVC, you must write a custom graphing View which must display the axes of the graph in addition to the plot of the program. Code will be provided on the class website which will draw axes with an origin at a given point and with a given scale, so you will not have to write the Core Graphics code for the axes, only for the graphing of the program itself. You probably will want to examine the provided axes-drawing code to understand how the scaling works before you do this or any of the following Required Tasks.

The mentioned code is available for download at Stanford. Add it to your project and create a new view class e.g. GraphView as subclass from UIView.
Continue reading “Assignment #3 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #4

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

Anytime a graph is on screen, the description of the program used to draw it (e.g. the result of your +descriptionOfProgram: method) should also be shown on screen somewhere sensible. This might be a different place on the iPhone versus the iPad.

As the description only changes when the program changes, we will run this task when the program is set, and put the description – if there is any – in the title:

- (void)setProgram:(id)program {
    _program = program;
    NSString *formula = [CalculatorBrain descriptionOfProgram:program];
    if ([formula isEqualToString:@""]) formula = @"Graph";
    self.title = formula;
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #3

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

Add a Graph button to your calculator’s user-interface that, when pressed, segues to a new MVC (that you will have to write) by pushing it onto the UINavigationController’s stack (on the iPhone). The new MVC graphs whatever program was in the calculator when the button was pressed. To draw the graph you will iterate over all the pixels in your view horizontally (x) and use +runProgram:usingVariableValues: to get the corresponding vertical (y) value. You will, of course, have to convert to/from your view’s coordinate system from/to a reasonable graph coordinate system. You will need a scale and origin to do this coordinate system conversion. If the user has not already chosen a scale and origin for the graph (see Required Tasks 7 & 8 below), pick a reasonable starting scale and origin.

… and still inside your storyboard, drag out a new view controller, place a new button called “Graph” into your calculator view controller and create a push segue from your new button to your new view controller.
Continue reading “Assignment #3 Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Task #2

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

The only variable button your calculator’s user-interface should present is x (so remove any others you added in Assignment 2 and you can remove your Test buttons and the UILabel which shows the value of the variables being used in the display).

Again inside your story board, delete the variable & test buttons as well as the label for the used variables. You might also want to rearrange the remaining buttons.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #3 Taks #1

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

The third assignment is yet a further extension of the calculator built in the previous assignments.

When your application is run on the iPhone, it must present the user-interface of your calculator from Assignment 2 inside a UINavigationController.

Just go to your storyboard, select the existing CalculatorViewController and embed it into a new UINavigationController clicking Editor -> Embed in -> Navigation Controller. Then double click the newly created navigation bar inside the CalculatorViewController and name it “Calculator”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Friday Session #3: Getting your application running on a device

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

This weeks Friday Session is/was called “Getting your application running on a device”. This lecture does not show up on iTunes, most likely, because it describes how to use a Stanford University Developer License.

However, connecting an actual device is not too difficult, once you received your valid developer license from Apple.

In Xcode go to the Organizer (button on the upper right hand side of the screen). There you will find a tab called Devices. Now connect your iPhone/iPad to your computer … and Xcode will do the rest … or at least will tell you what to do …

… and just recently Stanford provided some notes to for this session with the mysterious name “Section 3: Developing on Devices”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail