Spring 2010: Wednesday, March 31, 2010
Spring 2010: Wednesday, March 31, 2010
Spring 2010
E-mail
Questions are best sent to [email protected]
Sending directly to instructor or TA’s risks slow response.
Web Site
Very Important!
http://cs193p.stanford.edu
All lectures, assignments, code, etc. will be there.
This site will be your best friend when it comes to getting info.
Sonali
Friday 11am to 1pm
Thursday 1pm to 3pm
Gates B26B
Objective-C
Declaring and implementing objects
Sending messages between objects
Interface Builder
“Wiring up” objects to send messages to each other
Setting up the properties of objects
Xcode
Managing all your code
Running your application in the simulator
Controller
UILabel
Model View
UIButton UIButton
CalculatorBrain UIButton UIButton
UIButton UIButton UIButton
Model
@interface
@end
Model
@interface CalculatorBrain
@end
Model
#import <Foundation/Foundation.h>
@end
Model
#import <Foundation/Foundation.h>
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import <Foundation/Foundation.h>
- (void)setOperand:(double)anOperand;
- (double)performOperation:(NSString *)operation;
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
<code goes here>
return aDouble;
}
@end
Model
#import “CalculatorBrain.h”
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
<code goes here>
return aDouble;
}
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
[operation sendMessage:argument];
return aDouble;
}
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
[operation sendMessage:argument];
return aDouble;
} Square brackets mean “send a message.”
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
[operation sendMessage:argument];
return aDouble;
}
@end This is the object to send the message to
(in this case, the NSString called “operation” that was
passed as an argument to performOperation:).
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
[operation sendMessage:argument];
return aDouble;
} This is the message to send.
@end
Model
#import “CalculatorBrain.h”
@implementation CalculatorBrain
- (void)setOperand:(double)anOperand
{
<code goes here>
}
- (double)performOperation:(NSString *)operation
{
[operation sendMessage:argument];
return aDouble;
} And this is its one (in this case) argument.
@end
#import <UIKit/UIKit.h>
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operationPressed:(UIButton *)sender;
@end
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operationPressed:(UIButton *)sender;
@end
#import <UIKit/UIKit.h>
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operationPressed:(UIButton *)sender;
@end
Controller
#import <UIKit/UIKit.h>
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operationPressed:(UIButton *)sender;
@end
Controller
#import <UIKit/UIKit.h>
- (IBAction)digitPressed:(UIButton *)sender;
- (IBAction)operationPressed:(UIButton *)sender;
@end
CalculatorViewController.xib