Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
iOS
25.03.2013
The Platform and SDK
iOS
iPad
iPhone iPad Mini
Market share
System makes sure that objects that are needed are not
deleted, and when an object is not needed it is deleted
C++ vs. Objective-C
C++ Objective C
Large and complex code for OOP Simpler way of handling classes
and objects
Hello world example
Hello World
Task: Change a labels text using a button and an input box.
Drag and drop interface objects to you class h file to create connections
Add an action to the button
Right click on the button
Choose Touch Up
Inside and drag and
drop to the h file
- (IBAction)changeLabel:(id)sender;
@end
CLLocationCoordinate2D location;
location.latitude = 62.598;
Create a location
location.longitude = 29.745;
MKCoordinateRegion region;
MKCoordinateSpan span; Create a region
span.latitudeDelta=0.01;
span.longitudeDelta=0.01;
centered on location
region.span=span;
region.center=location;
Header file:
@interface LocationController : NSObject <CLLocationManagerDelegate>
// Class members: Location manager and current location container
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic, retain) CLLocation *currentLocation;
@implementation LocationController
@synthesize locationManager, currentLocation; // Autogenerate getters and setters
-(void) startLocationManager:(CLLocationAccuracy)accuracy {
if(self.locationManager != nil) {
self.locationManager.desiredAccuracy = accuracy;
self.locationManager.distanceFilter = 0;
self.locationManager.headingFilter = 0;
// Start location updates
if([CLLocationManager locationServicesEnabled]){
[self.locationManager startUpdatingLocation];
}
}
}
-(void) stopLocationManager {
[self.locationManager stopUpdatingLocation];
}
Handling location