Skip to content

Commit

Permalink
Fixed memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishikawakatsumi committed Dec 19, 2011
1 parent 2c9e52e commit 7901985
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
22 changes: 13 additions & 9 deletions Classes/DetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,19 @@ - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnn
}
*/

MKPinAnnotationView *annotationView;
NSString* identifier = @"Pin";
annotationView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if(nil == annotationView) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
static NSString* identifier = @"Pin";
if ([annotation isKindOfClass:[FNACustomAnnotation class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if(nil == annotationView) {
annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
annotationView.animatesDrop = YES;
annotationView.canShowCallout = NO;
} else {
annotationView.annotation = annotation;
}
return annotationView;
}
annotationView.animatesDrop = YES;
annotationView.canShowCallout = NO;
return annotationView;
return nil;
}


Expand Down Expand Up @@ -126,7 +130,7 @@ - (void)viewDidLoad {
MKCoordinateRegion cr = MKCoordinateRegionMake(co,span);
[_mapView setRegion:cr animated:YES];

FNACustomAnnotation* annotation = [[FNACustomAnnotation alloc] initWithLocation:co];
FNACustomAnnotation* annotation = [[[FNACustomAnnotation alloc] initWithLocation:co] autorelease];
[_mapView removeAnnotations:_mapView.annotations];
[_mapView addAnnotation:annotation];

Expand Down
10 changes: 5 additions & 5 deletions External/NSString+URLEncoding/NSString+URLEncoding.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#import "NSString+URLEncoding.h"
@implementation NSString (URLEncoding)
-(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding {
return (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
NULL,
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
CFStringConvertNSStringEncodingToEncoding(encoding));
return [(NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)self,
NULL,
(CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
CFStringConvertNSStringEncodingToEncoding(encoding)) autorelease];
}
@end

0 comments on commit 7901985

Please sign in to comment.