Skip to content

Instantly share code, notes, and snippets.

@soffes
Created March 23, 2010 05:17
Show Gist options
  • Save soffes/340858 to your computer and use it in GitHub Desktop.
Save soffes/340858 to your computer and use it in GitHub Desktop.
//
// 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
//
// 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
@EO2
Copy link

EO2 commented Sep 7, 2011

Thanks for the quick update :)

@ZavenArra
Copy link

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