地図に目印を追加しようとしています。目印は、名簿の完全に外側の住所から作成されます。
目印が地図に表示されていますが、ピンチしてズームインしようとするとクラッシュします。
*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer objectForKey:]: unrecognized selector sent to instance 0x4569dc0'
アドレスの設定方法は次のとおりです。
id theAddress = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat: @"%@ - %@", theAddress1 ? theAddress1 : @"", theAddress2 ? theAddress2 : @""], kABPersonAddressStreetKey,
theCity ? theCity : @"", kABPersonAddressCityKey,
theState ? theState : @"", kABPersonAddressStateKey,
theZip ? theZip : @"", kABPersonAddressZIPKey,
theCountry ? theCountry : @"", kABPersonAddressCountryKey,
nil];
アドレスレコードの値を使用してアドレスの座標を見つけ(この質問と回答からこれを行う方法を学びました)、それをマップに追加します。
[mapView addAnnotation: [[[MKPlacemark alloc] initWithCoordinate: theCoordinate
addressDictionary: theAddress] autorelease]];
クラッシュは間違いなくこのMKPlacemarkが原因のようです。まるで、addAnnotationステートメントをコメントアウトしたかのように、コードはクラッシュしません。
何が起こっているのか分かりますか?アドレスレコードが足りないと思いますが、エラーメッセージは本当に役に立ちません。