Note that there are some explanatory texts on larger screens.

plurals
  1. POCrash when zooming into a MKMapView with a MKPlacemark
    text
    copied!<p>I'm trying to add a placemark to a map. The placemark is built from an address completely outside of Address Book.</p> <p>My placemark is appearing on the map, but when I try to pinch to zoom in I get a crash:</p> <pre><code>*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0' </code></pre> <p>Here's how I'm setting up the address:</p> <pre><code>id theAddress = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat: @"%@ - %@", theAddress1 ? theAddress1 : @"", theAddress2 ? theAddress2 : @""], kABPersonAddressStreetKey, theCity ? theCity : @"", kABPersonAddressCityKey, theState ? theState : @"", kABPersonAddressStateKey, theZip ? theZip : @"", kABPersonAddressZIPKey, theCountry ? theCountry : @"", kABPersonAddressCountryKey, nil]; </code></pre> <p>I use the values in the address record to find the coordinate for the address (learned how to do this from <a href="https://stackoverflow.com/questions/1451792/how-can-i-determine-a-cllocation-or-mkplacemark-from-an-address">this question &amp; answer</a>), then I add it to my map:</p> <pre><code>[mapView addAnnotation: [[[MKPlacemark alloc] initWithCoordinate: theCoordinate addressDictionary: theAddress] autorelease]]; </code></pre> <p>The crash definitely seems to be caused by this MKPlacemark, as if I comment out the addAnnotation statement the code doesn't crash.</p> <p>Any idea what's going on? I'm guessing I haven't got enough in the address record, but the error message is really unhelpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload