Skip to content

Instantly share code, notes, and snippets.

View egold's full-sized avatar
🐒
...

Eric Goldberg egold

🐒
...
View GitHub Profile
@dickbrouwer
dickbrouwer / gist:2368787
Created April 12, 2012 16:19
Create singleton using dispatch_once_t
+ (UserManager *)sharedManager {
static dispatch_once_t once;
dispatch_once(&once, ^ {
_sharedManager = [[self alloc] init];
});
return _sharedManager;
}
@kwylez
kwylez / gist:1952410
Created March 1, 2012 19:13
Forward geocoding support for ios4 and ios5
// Block param typedef
typedef void (^ForwardGeoCompletionBlock)(CLLocationCoordinate2D coords);
// Fetch Records Method
- (void)fetchForwardGeocodeAddress:(NSString *)address withCompletionHanlder:(ForwardGeoCompletionBlock)completion {
if (NSClassFromString(@"CLGeocoder")) {
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
@andrewgleave
andrewgleave / iOSMapKitFitAnnotations.m
Last active May 17, 2024 02:07
Zooms out a MKMapView to enclose all its annotations (inc. current location)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}