cs193p – Lecture #1 – iOS, MVC, Objective-C

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

Lecture #1 is an general introduction of the course with an overview about iOS, MVC and Object C.

Paul Hegarty stresses the importance of being familiar with object oriented programming as prerequisites for the course and that it is not for absolute beginners.
Continue reading “cs193p – Lecture #1 – iOS, MVC, Objective-C”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Season – Winter 2013

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

Stanfords course cs193p has started its Winter session. The videos of the lectures are available at iTunes. Sample code and slides are (or should be) available directly at Stanford. Like last summer it is accompanied by peer collaboration on Piazza.

The course material from previous seasons is still available:

Summer 2012 / Fall 2011
videos downloads

Fall 2010
videos downloads

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #2 – Extra Task

Add a memo-function to store a number

Start my rearranging the buttons to make space for three new ones:

iOS Dev – Assignment #2 - Extra Task – Additional Buttons
iOS Dev – Assignment #2 – Extra Task – Additional Buttons

Create a variable to store the value:

float numberInMemory;

Initialize it:

- (void)viewDidLoad
{
    ...
    numberInMemory = 0;
}

And connect the buttons to suitable methods:

- (IBAction)addMemoryButtonPressed:(UIButton *)sender {
    numberInMemory += [self.numberTextField.text floatValue];
}

- (IBAction)subtractMemoryButtonPresed:(UIButton *)sender {
    numberInMemory -= [self.numberTextField.text floatValue];
}

- (IBAction)getMemoryButtonPressed:(UIButton *)sender {
     self.numberTextField.text = [NSString stringWithFormat:@"%@", [NSNumber numberWithFloat:numberInMemory]];
}
FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #2 – Task #4

Delegation The BasicCalculator communicates its result to a delegate. This asynchronous implementation is a bit overhead in this simple example, but think of a scientific calculator with more elaborate functionality. You can start a very complex operation and the Calculator-Class takes care of processing this operation in the background. After some time it finishes and communicates its result to the controller. Have a close look at the implementation of the delegation in the Basic- Calculator class. Now make your ViewController class the delegate of the calculator and make the project a fully working calculator.

When the view has loaded initiate the calculator and set the view controller as delegate of the calculator:
Continue reading “iOS Dev – Assignment #2 – Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #2 – Task #3

Protocols In the header file of the BasicCalculator you will find a protocol that defines a method

- (void)operationDidCompleteWithResult:(NSNumber*)result;

Make your ViewController-Class comply to that protocol.

First define the view controller as delegate of the calculator, then define required method of the protocol and let it display the result in the view:

// ViewController.h
@interface ViewController : UIViewController <BasicCalculatorDelegate>

- (void)operationDidCompleteWithResult:(NSNumber*)result;

// ViewController.m
- (void)operationDidCompleteWithResult:(NSNumber*)result {
    self.numberTextField.text = [NSString stringWithFormat:@"%@", result];
}

Please note that at the moment the view controller class only complies to the protocol. Even if its methods would already work as intended, nothing changed in the functionality compared with the previous task, because nobody actually uses the protocol …

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #2 – Task #2

Check some edge-cases Division by 0, double decimal points, leading 0s, …

Division by 0 is already handled in the code from the previous task.

For the double decimal points expand the commaPressed: method like in assignment #1:
Continue reading “iOS Dev – Assignment #2 – Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

iOS Dev – Assignment #2 – Task #1

Model-View-Controller Since a calculator is something that might be used in various situations, you decide to rewrite your code to something more reusable. One advantage of MVC is that you can exchange the view but keep your model and parts of your controller. We provide you with a template for a class called BasicCalculator. Extend that class to provide a fully functional basic calculator. This class is your model.

The provided template is similar to the one from Assignment #1, where the calculator functionality is moved to the new model class. You could either use your code from the previous assignment and adjust it or redo the changes from the previous assignment inside the new template. Here we will choose the second approach.

First link the missing number buttons to the view controller class and change the tags of the buttons accordingly.
Continue reading “iOS Dev – Assignment #2 – Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail