Stanford Cource(1)MVC and Object-C
1. IOS Layer
1.1 Core OS
OSX Kernel Power Management
Mach 3.0 Keychain Access
BSD Certificates
Socket File System
Security Bonjour
1.2 Core Services
Collections Core Location
Address Book Net Services
Networking Threading
File Access References
SQLite URL utilities
1.3 Media
Core Audio JPEG, PNG TIFF
OpenAL PDF
Audio Mixing Quartz
Audio recording Core Animation
Video Playback OpenGL ES
1.4 Cocoa Touch
Multi-Touch Alerts
Core Motion Web View
View Hierarchy Map Kit
Localization Image Picker
Controls Camera
2. Tools
Xcode4 Instruments
3. MVC
3.1 Model
what does your application does?
3.2 View
Show your model
3.3 Controller
How your models show on screen
Controller send message to Model
Controller send message to View(outlet)
View talk to Controller(Tareget)
(Will Did Should Delegate)
View do not own the data they display.
View get data source from Controller (Data at, Count)
Model send Notification & KVO to Controller
4. Language Objective-C
Interface
Spaceship.h
#import "vehicle.h"
#import "Planet.h"
@interface Spaceship: Vehicle
//declaration of public method
@property (nonatomic) double topSpeed;
- (void) orbitPlanet:(Planet *) aPlanet
atAltitude:(double)km;
- (void) setTopSpeed:(double)percentSpeedOfLight;
- (double) topSpeed
@end
Implementation
Spaceship.m
#import "Spaceship.h"
@interface Spaceship()
//declaration of private methods
@property (nonatomic, strong) Wormhole *nearestWormhole;
@end
@implementation Spaceship
@synthesize topSpeed = _topSpeed;
@synthesize nearestWormhole = _nearestWormhole;
- (void) setTopSpeed:(double)speed
{
//
_topSpeed = speed;
}
- (double) topSpeed
{
//
return _topSpeed;
}
- (void)orbitPlanet:(Planet *)aPlanet atAltitude:(double) km
{
//put codes here
double speed = [self topSpeed]; // self.topSpeed
if(speed > MAX_RELATIVE) speed = MAX_RELATIVE;
[[self nearestWormhole] travelToPlanet:aPlanet
atSpeed:speed];
}
@end
@property @sythesize generate getter and setter for us.
All property are zero when object are created.
references:
www.stanford.edu
Stanford Cource(1)MVC and Object-C
猜你喜欢
转载自sillycat.iteye.com/blog/1747763
今日推荐
周排行