Lecture #6: Multiple MVCs and Segues

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

Lecture six is named “6. Multiple MVCs and Segues (October 13, 2011)” and can be found at iTunes. Its slides are available at Stanford.

It starts with a continuation of the demo from the second half of the previous lecture, adding features to Happiness namely delegates. The code for this demo is available directly at Stanford, and github.
Continue reading “Lecture #6: Multiple MVCs and Segues”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Lecture #5: Protocols and Gestures

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

The first lecture of the third week of the course is named “Protocols and Gestures (October 11, 2011)” and can be found at iTunes. Its slides are available at Stanford.

It starts with a theoretical part presenting

  • Autorotation,
  • Protocols and
  • Gesture Recognizers.

When a device rotates you can choose how your application should react:
Continue reading “Lecture #5: Protocols and Gestures”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #2 Extra Task #1

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

Enhance your application to show the user error conditions like divide by zero, square root of a negative number, and insufficient operands. One way to do this (and to get more experience with using id) might be to have runProgram:usingVariableValues: in CalculatorBrain return an id (instead of a double) which is an NSNumber with the result or an NSString with the description of an error if it encounters one. Then update your Controller to use introspection on the return value and display the appropriate thing to the end-user.

Mainly the API of the CalculatorBrain has to be changed from double to id:
Continue reading “Assignment #2 Extra Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Assignment #2 Task #4

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

Add an Undo button to your calculator. Hitting Undo when the user is in the middle of typing should take back the last digit or decimal point pressed until doing so would clear the display entirely at which point it should show the result of running the brain’s current program in the display (and now the user is clearly not in the middle of typing, so take care of that). Hitting Undo when the user is not in the middle of typing should remove the top item from the program stack in the brain and update the user- interface.

This task can be implemented with 1 method in your Controller (of about 5-6 lines of code, assuming you’ve factored out the updating of your user-interface into a single method somewhere) and 1 method (with 1 line of code) in your Model. If it’s taking much more than that, you might want to reconsider your approach.

The first part of this task has already been implemented in the previous assignment. So we have to adjust the backSpace method to achieve the rest. To receive the result of the last program when the last entry is cleared we just add

        [self updateCalculatorView];

Continue reading “Assignment #2 Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail