• Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,706
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
18
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide






















Transcript

  • 1. iPhone geo hacking 101 Michael Dales
  • 2. • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? • where should I be?
  • 3. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? • where should I be?
  • 4. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? MapKit • where should I be?
  • 5. CoreLocation • where am I? • no, really, I’m a human. where am I? • Can you show me where I am? • Can you show me where it is? MapKit • where should I be? AddressBook
  • 6. locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation];
  • 7. - (void)locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation { NSString *latitudeString = [[NSString alloc] initWithFormat: @"%g", newLocation.coordinate.latitude]; latitudeLabel.text = latitudeString; [latitudeString release]; NSString *longitudeString = [[NSString alloc] initWithFormat: @"%g", newLocation.coordinate.longitude]; longitudeLabel.text = longitudeString; [longitudeString release]; }
  • 8. CLLocation • Location info • lat, long, accuracy • Altitude info, speed info, heading info • ask distance from another point
  • 9. • Remember the user! • Battery matters to them • Also available on the Mac
  • 10. MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate: coordinate]; geocoder.delegate = self; [geocoder start];
  • 11. MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate: coordinate]; geocoder.delegate = self; [geocoder start]; and a little later... - (void)reverseGeocoder: (MKReverseGeocoder *)geocoder didFindPlacemark: (MKPlacemark *)pplacemark { self.placemark = pplacemark; geocoder.delegate = nil; [geocoder autorelease]; }
  • 12. MKPlacemark NSString *thoroughfare; // street address, eg 1 Infinite Loop NSString *subThoroughfare; NSString *locality; // city, eg. Cupertino NSString *subLocality; // neighborhood, landmark, common name, etc NSString *administrativeArea; // state, eg. CA NSString *subAdministrativeArea; // county, eg. Santa Clara NSString *postalCode; // zip code, eg 95014 NSString *country; // eg. United States NSString *countryCode; // eg. US
  • 13. maps demo
  • 14. set where to look MKCoordinateRegion region; region.center = lastPoint.coordinate; region.span.latitudeDelta = 0.002; region.span.longitudeDelta = 0.002; [mapView setRegion: region animated: YES];
  • 15. annotations @interface LocationDemoAnnotation : NSObject <MKAnnotation, MKReverseGeocoderDelegate> { // essential CLLocationCoordinate2D coordinate; } @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; - (id)initWithCoordinate: (CLLocationCoordinate2D)coord; - (NSString *)title; - (NSString *)subtitle;
  • 16. making it personal ABAddressBook *addressBook = [ABAddressBook addressBook]; ABPerson *me = [addressBook me]; id home = [me valueForProperty: kABAddressProperty];
  • 17. making it personal ABAddressBook *addressBook = [ABAddressBook addressBook]; ABPerson *me = [addressBook me]; id home = [me valueForProperty: kABAddressProperty]; 2010-03-12 13:34:09.804 MacLocationTest[34432:a0b] ABPerson (0x20009d180) { ABPersonFlags : 0 Address :{ home { City = Impington; Country = UK; State = Cambridge; Street = "42 North Road"; ZIP = "CB99 9ZX"; } } Creation : 2010-01-04 18:00:01 +0000 First : Michael Last : Dales Modification : 2010-03-12 13:29:27 +0000 Unique ID : 506661FE-8D0D-407F-AEAB-61699D59E943:ABPerson }
  • 18. what’s left • Talking to something else • ASIHTTPRequest • JSON Framework