0

地図に目印を追加しようとしています。目印は、名簿の完全に外側の住所から作成されます。

目印が地図に表示されていますが、ピンチしてズームインしようとするとクラッシュします。

*** -[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ステートメントをコメントアウトしたかのように、コードはクラッシュしません。

何が起こっているのか分かりますか?アドレスレコードが足りないと思いますが、エラーメッセージは本当に役に立ちません。

4

2 に答える 2

1

どこかで NSDictionary オブジェクトを過剰に解放しています。見つける方法は次のとおりです。

[プロジェクト] メニューで、[アクティブな実行可能ファイルの編集] を選択します。Arguments タブで、「環境に設定する変数:」ブロックに nameNSZombieEnabledと valueの項目を追加しますYES

ハッピーゾンビハンティング。

于 2009-12-18T07:28:40.773 に答える
1

Is something happening to that theAddress NSDictionary between when you create it and when you pass it to MKPlacemark's init method? I ask because it seems like you're crashing because your code is trying to treat a CALayer object like it's a collection class (that is, like it has an objectForKey: method), and the only collection class I see in there is that address dictionary.

于 2009-12-18T07:45:01.027 に答える