Created
March 23, 2010 05:17
-
-
Save soffes/340858 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SSMapAnnotation.h | |
// Public Domain | |
// | |
// Created by Sam Soffes on 3/22/10. | |
// Copyright 2010 Sam Soffes. All rights reserved. | |
// | |
#import <MapKit/MapKit.h> | |
@interface SSMapAnnotation : NSObject <MKAnnotation> | |
@property (nonatomic, assign) CLLocationCoordinate2D coordinate; | |
@property (nonatomic, copy) NSString *title; | |
@property (nonatomic, copy) NSString *subtitle; | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate; | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle; | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle subtitle:(NSString *)aSubtitle; | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate; | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle; | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle subtitle:(NSString *)aSubtitle; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SSMapAnnotation.m | |
// Public Domain | |
// | |
// Created by Sam Soffes on 3/22/10. | |
// Copyright 2010 Sam Soffes. All rights reserved. | |
// | |
#import "SSMapAnnotation.h" | |
@implementation SSMapAnnotation | |
@synthesize coordinate = _coordinate; | |
@synthesize title = _title; | |
@synthesize subtitle = _subtitle; | |
#pragma mark - Class Methods | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate { | |
return [self mapAnnotationWithCoordinate:aCoordinate title:nil subtitle:nil]; | |
} | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle { | |
return [self mapAnnotationWithCoordinate:aCoordinate title:aTitle subtitle:nil]; | |
} | |
+ (SSMapAnnotation *)mapAnnotationWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle subtitle:(NSString *)aSubtitle { | |
SSMapAnnotation *annotation = [[self alloc] init]; | |
annotation.coordinate = aCoordinate; | |
annotation.title = aTitle; | |
annotation.subtitle = aSubtitle; | |
return annotation; | |
} | |
#pragma mark - Initializers | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate { | |
return [self initWithCoordinate:aCoordinate title:nil subtitle:nil]; | |
} | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle { | |
return [self initWithCoordinate:aCoordinate title:aTitle subtitle:nil]; | |
} | |
- (SSMapAnnotation *)initWithCoordinate:(CLLocationCoordinate2D)aCoordinate title:(NSString *)aTitle subtitle:(NSString *)aSubtitle { | |
if ((self = [super init])) { | |
self.coordinate = aCoordinate; | |
self.title = aTitle; | |
self.subtitle = aSubtitle; | |
} | |
return self; | |
} | |
@end |
Found this from WLSimpleMapAnnotation page in LaFrance's blog.
Thanks guys!
On line 63 there is an assignment in the if..
Xcode told me that perhaps it should be:
if (self == [super init]) {
:)
Best Regards
E
@EO2 it should be like if ((self = [super init]))
since we're checking if the assigned worked not if it actually equal.
Thanks for the quick update :)
Thanks, very useful shortcut through some tedious programming. Found from WLSimpleMapAnnotation. Note that I believe you can remove _dealloc and autorelease calls for new ARC compiler.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how i use this files