Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:39:23+00:00 2026-05-24T19:39:23+00:00

For some reason my mapview and annotations work fine without dequeueReusableAnnotationViewWithIdentifier, but as soon

  • 0

For some reason my mapview and annotations work fine without dequeueReusableAnnotationViewWithIdentifier, but as soon as I uncomment it and try to use it my program keeps crashing. The error is an EXC_BAD_ACCESS.

#import "ThirdViewController.h"
#import "MKMapView+ZoomLevel.h"
#import "CalcBlockID.h"
#import "CalcBorderBlocks.h"
#import "MakeBlocksQuery.h"
#import "Block.h"


@implementation ThirdViewController
@synthesize mapView = mapView_;
@synthesize zoomLabel = zoomLabel_;

@synthesize blockID = blockID_;
@synthesize blockArray = blockArray_;
@synthesize query = query_;

static ThirdViewController *currentInstance;

 - (void)viewDidLoad {
   [super viewDidLoad];
   blockStorage_ = [BlockStorage instance];
   restDelegate_ = [RESTDelegate instance];
   currentInstance = self;

   self.mapView.delegate = self;
   self.mapView.showsUserLocation = YES;
}

- (void)didReceiveMemoryWarning {
  // Releases the view if it doesn't have a superview.
  [super didReceiveMemoryWarning];

  // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
  [super viewDidUnload];
  self.mapView = nil;
  self.zoomLabel = nil;

  self.blockID = nil;
  self.blockArray = nil;
  self.query = nil;
}

- (void)dealloc {
  [mapView_ release];
  [zoomLabel_ release];

  [blockID_ release];
  [blockArray_ release];
  [query_ release];
  [super dealloc];
}

+ (ThirdViewController *)returnSelf {
  return currentInstance;
}

#pragma mark - Key Methods

// Called when objects are recieved from RESTDelegate class
- (void)addAnnotations:(NSArray *)blocks {
  [self.mapView addAnnotations:blocks];
}

// Called whenever the current map view region is changed.
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
  latitude_ = self.mapView.region.center.latitude;
  longitude_ = self.mapView.region.center.longitude;
  zoom_ = [self.mapView zoomLevel];

  CalcBlockID *calcBlockID = [[CalcBlockID alloc] init];
  self.blockID = [calcBlockID calcWithLat:latitude_ andLong:longitude_ andZoom:zoom_];
  [calcBlockID release];

  CalcBorderBlocks *calcBorderBlocks = [[CalcBorderBlocks alloc] init];
  self.blockArray = [calcBorderBlocks calcWithBlockID:self.blockID];
  [calcBorderBlocks release];

  MakeBlocksQuery *makeBlocksQuery = [[MakeBlocksQuery alloc] init];
  self.query = [makeBlocksQuery makeWithBlockArray:self.blockArray];
  [makeBlocksQuery release];

  if (self.query) {
    [restDelegate_ loadBlocksWithQuery:self.query];
  }
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
  // If annotation is of user's location, return nil to use default view.
  if ([annotation isKindOfClass:[MKUserLocation class]]) {
    return nil;
  }

  // Try to dequeue an existing pin.
  static NSString *viewIdentifier = @"annotationView";
  MKPinAnnotationView *pinAnnotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier];

  if (!pinAnnotationView) {
    pinAnnotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier];
    pinAnnotationView.pinColor = MKPinAnnotationColorPurple; // PURPLE!
  } else {
    pinAnnotationView.annotation = annotation;
  }
  return [pinAnnotationView autorelease];
}

@end

Here’s one of the crash reports:

0x0163408c  <+0000>  mov    0x8(%esp),%ecx
0x01634090  <+0004>  mov    0x4(%esp),%eax
0x01634094  <+0008>  test   %eax,%eax
0x01634096  <+0010>  je     0x16340ea <objc_msgSend+94>
0x01634098  <+0012>  mov    (%eax),%edx
0x0163409a  <+0014>  push   %edi
0x0163409b  <+0015>  mov    0x8(%edx),%edi
0x0163409e  <+0018>  push   %esi
0x0163409f  <+0019>  mov    (%edi),%esi
0x016340a1  <+0021>  mov    %ecx,%edx
0x016340a3  <+0023>  shr    $0x2,%edx
0x016340a6  <+0026>  and    %esi,%edx
0x016340a8  <+0028>  mov    0x8(%edi,%edx,4),%eax
0x016340ac  <+0032>  test   %eax,%eax
0x016340ae  <+0034>  je     0x16340b9 <objc_msgSend+45>
0x016340b0  <+0036>  cmp    (%eax),%ecx
0x016340b2  <+0038>  je     0x16340d0 <objc_msgSend+68>
0x016340b4  <+0040>  add    $0x1,%edx
0x016340b7  <+0043>  jmp    0x16340a6 <objc_msgSend+26>
0x016340b9  <+0045>  pop    %esi
0x016340ba  <+0046>  pop    %edi
0x016340bb  <+0047>  mov    0x4(%esp),%eax
0x016340bf  <+0051>  mov    (%eax),%eax
0x016340c1  <+0053>  jmp    0x16340d9 <objc_msgSend+77>
0x016340c3  <+0055>  nopw   0x0(%eax,%eax,1)
0x016340c9  <+0061>  nopl   0x0(%eax)
0x016340d0  <+0068>  mov    0x8(%eax),%eax
0x016340d3  <+0071>  pop    %esi
0x016340d4  <+0072>  pop    %edi
0x016340d5  <+0073>  xor    %edx,%edx
0x016340d7  <+0075>  jmp    *%eax
0x016340d9  <+0077>  sub    $0x4,%esp
0x016340dc  <+0080>  push   %ecx
0x016340dd  <+0081>  push   %eax
0x016340de  <+0082>  call   0x16211ae <_class_lookupMethodAndLoadCache>
0x016340e3  <+0087>  add    $0xc,%esp
0x016340e6  <+0090>  xor    %edx,%edx
0x016340e8  <+0092>  jmp    *%eax
0x016340ea  <+0094>  call   0x16340ef <objc_msgSend+99>
0x016340ef  <+0099>  pop    %edx
0x016340f0  <+0100>  mov    0xbba21(%edx),%eax
0x016340f6  <+0106>  test   %eax,%eax
0x016340f8  <+0108>  je     0x1634100 <objc_msgSend+116>
0x016340fa  <+0110>  mov    %eax,0x4(%esp)
0x016340fe  <+0114>  jmp    0x1634098 <objc_msgSend+12>
0x01634100  <+0116>  mov    $0x0,%edx
0x01634105  <+0121>  ret    
0x01634106  <+0122>  xchg   %ax,%ax
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:39:24+00:00Added an answer on May 24, 2026 at 7:39 pm

    The problem is that you’re over-releasing the dequeued annotation because you have an unbalanced release.

    MKPinAnnotationView *pinAnnotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier]; // +0 retain count
    
    if (!pinAnnotationView) {
        pinAnnotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier]; // +1 retain count
        // ...
    }
    return [pinAnnotationView autorelease]; // release!
    

    So instead you should use

    [[self.mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier] retain]
    

    or

    [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier] autorelease]
    // and don't -autorelease later.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, I can't get this program to work. I've had other CS
For some reason, when I use [mapView addOverlay:], nothing happens. Code: NSData* dataLat =
For some reason, when I try to install SQL Server 2008 Express , I
For some reason, Section 1 works but Section 2 does not. When run in
For some reason, I can't get embedded firebird sql to work on Windows using
For some reason the following C# Console program always outputs: 32 False wtf=0 What
I'm trying to use a mapview object in my app, but I need to
For some reason, I can't use jQuery. This is my code : document.addEventListener(touchstart, function(e)
For some reason, .NET Reflector throws an exception when I try to reflect on
For some reason I can't seem to get the basic example to work, provided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.