diff --git a/SVGeocoder/SVGeocoder.h b/SVGeocoder/SVGeocoder.h index 5a46683..8997003 100644 --- a/SVGeocoder/SVGeocoder.h +++ b/SVGeocoder/SVGeocoder.h @@ -10,6 +10,8 @@ #import #import +#import "SVPlacemark.h" + @protocol SVGeocoderDelegate; @interface SVGeocoder : NSObject { @@ -20,7 +22,7 @@ - (SVGeocoder*)initWithCoordinate:(CLLocationCoordinate2D)coordinate; - (SVGeocoder*)initWithAddress:(NSString *)address inRegion:(MKCoordinateRegion)region; -- (SVGeocoder*)initWithAddress:(NSString*)address; +- (SVGeocoder*)initWithAddress:(NSString *)address; - (void)startAsynchronous; @@ -29,7 +31,7 @@ @protocol SVGeocoderDelegate -- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark; +- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(SVPlacemark *)placemark; - (void)geocoder:(SVGeocoder *)geocoder didFailWithError:(NSError *)error; @end \ No newline at end of file diff --git a/SVGeocoder/SVGeocoder.m b/SVGeocoder/SVGeocoder.m index 16766a3..8852e72 100644 --- a/SVGeocoder/SVGeocoder.m +++ b/SVGeocoder/SVGeocoder.m @@ -125,7 +125,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection { } } - MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(lat, lng) addressDictionary:formattedAddressDict]; + SVPlacemark *placemark = [[SVPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(lat, lng) addressDictionary:formattedAddressDict]; [formattedAddressDict release]; NSLog(@"SVGeocoder -> Found Placemark"); diff --git a/SVGeocoder/SVPlacemark.h b/SVGeocoder/SVPlacemark.h new file mode 100644 index 0000000..dacd727 --- /dev/null +++ b/SVGeocoder/SVPlacemark.h @@ -0,0 +1,18 @@ +// +// SVPlacemark.h +// SVGeocoder +// +// Created by Sam Vermette on 01.05.11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import +#import + +@interface SVPlacemark : MKPlacemark { + +} + +@property (nonatomic, readwrite) CLLocationCoordinate2D coordinate; + +@end diff --git a/SVGeocoder/SVPlacemark.m b/SVGeocoder/SVPlacemark.m new file mode 100644 index 0000000..b3025c5 --- /dev/null +++ b/SVGeocoder/SVPlacemark.m @@ -0,0 +1,33 @@ +// +// SVPlacemark.m +// SVGeocoder +// +// Created by Sam Vermette on 01.05.11. +// Copyright 2011 __MyCompanyName__. All rights reserved. +// + +#import "SVPlacemark.h" + + +@implementation SVPlacemark + +@synthesize coordinate; + +- (id)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate addressDictionary:(NSDictionary *)addressDictionary { + + if(self = [super initWithCoordinate:aCoordinate addressDictionary:addressDictionary]) + self.coordinate = aCoordinate; + + return self; +} + +- (NSString*)description { + + NSDictionary *coordDict = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:self.coordinate.latitude], @"latitude", [NSNumber numberWithFloat:self.coordinate.longitude], @"longitude", nil]; + + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:coordDict, @"coordinate", self.addressDictionary, @"address", nil]; + + return [dict description]; +} + +@end diff --git a/Sample/Classes/SVGeocoderAppViewController.m b/Sample/Classes/SVGeocoderAppViewController.m index 4cf9c48..ea6d0d6 100644 --- a/Sample/Classes/SVGeocoderAppViewController.m +++ b/Sample/Classes/SVGeocoderAppViewController.m @@ -24,9 +24,9 @@ - (void)geocode { [geocodeRequest startAsynchronous]; } -- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark { +- (void)geocoder:(SVGeocoder *)geocoder didFindPlacemark:(SVPlacemark *)placemark { - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Placemark Found!" message:[[placemark addressDictionary] description] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Placemark Found!" message:[placemark description] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alertView show]; [alertView release]; } diff --git a/Sample/SVGeocoder.xcodeproj/project.pbxproj b/Sample/SVGeocoder.xcodeproj/project.pbxproj index 3c5c4fd..d1ea762 100755 --- a/Sample/SVGeocoder.xcodeproj/project.pbxproj +++ b/Sample/SVGeocoder.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 220BC2ED1347FDF600D0DD26 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 220BC2E91347FDF600D0DD26 /* CHANGELOG.md */; }; 220BC2EE1347FDF600D0DD26 /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 220BC2EB1347FDF600D0DD26 /* JSONKit.m */; }; 220BC2EF1347FDF600D0DD26 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 220BC2EC1347FDF600D0DD26 /* README.md */; }; + 2215D386136DE916007A3351 /* SVPlacemark.m in Sources */ = {isa = PBXBuildFile; fileRef = 2215D385136DE916007A3351 /* SVPlacemark.m */; }; 227829E313061C8C00CCA1B9 /* SVGeocoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 227829CB13061C8C00CCA1B9 /* SVGeocoder.m */; }; 22B7DFAE1305BA170014DB40 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B7DFAD1305BA170014DB40 /* AddressBook.framework */; }; 22B7DFEB1305BA250014DB40 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B7DFEA1305BA250014DB40 /* MapKit.framework */; }; @@ -34,6 +35,8 @@ 220BC2EA1347FDF600D0DD26 /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = ""; }; 220BC2EB1347FDF600D0DD26 /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = ""; }; 220BC2EC1347FDF600D0DD26 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; + 2215D384136DE916007A3351 /* SVPlacemark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVPlacemark.h; sourceTree = ""; }; + 2215D385136DE916007A3351 /* SVPlacemark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVPlacemark.m; sourceTree = ""; }; 227829CA13061C8C00CCA1B9 /* SVGeocoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGeocoder.h; sourceTree = ""; }; 227829CB13061C8C00CCA1B9 /* SVGeocoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGeocoder.m; sourceTree = ""; }; 22B7DFAD1305BA170014DB40 /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; }; @@ -101,6 +104,8 @@ children = ( 227829CA13061C8C00CCA1B9 /* SVGeocoder.h */, 227829CB13061C8C00CCA1B9 /* SVGeocoder.m */, + 2215D384136DE916007A3351 /* SVPlacemark.h */, + 2215D385136DE916007A3351 /* SVPlacemark.m */, 220BC2E81347FDF600D0DD26 /* JSONKit */, ); name = SVGeocoder; @@ -220,6 +225,7 @@ 28D7ACF80DDB3853001CB0EB /* SVGeocoderAppViewController.m in Sources */, 227829E313061C8C00CCA1B9 /* SVGeocoder.m in Sources */, 220BC2EE1347FDF600D0DD26 /* JSONKit.m in Sources */, + 2215D386136DE916007A3351 /* SVPlacemark.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };