を逆にすると、次のとおりです。ドキュメントGMSMutablePathによるGMSMutablePathアレイ
GMSMutablePath is a dynamic (resizable) array of CLLocationCoordinate2D. [Google Documentation]
https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_mutable_path
私はパスの座標の順序を逆にしたいです。通常、私が使用する配列を持つ:
[[array123 reverseObjectEnumerator] allObjects];
が、NSArrayの機能のどれもがそれに動作しませんし、私はNSArrayのかNSMutableArrayのにキャストしてみた場合、私はちょうど赤い旗を取得します。
GMSMutablePathの要素の順序を逆にする方法、またはNSArrayに正しくキャストする方法を教えてください。
NSMutableArrayから継承されたオブジェクトではありません。あなたはそのようにキャストすることはできません。単純にforループで 'replaceCoordinateAtIndex:withCoordinate:'を使って手作業でやってみましょう。これはおそらく次のようになります: 'for(NSUInteger i1 = 0; i1 <[myPath count]/2; i1 ++){NSUInteger i2 = [myPath count] -i1; CLLocationCoordinate2D * coord1 = [myPath coordinateAtIndex:i1]; CLLocationCoordinate2D * coord2 = [myPath coordinateAtIndex:i2]; [myPath replaceCoordinateAtIndex:i1 withCoordinate:coord2]; [myPath replaceCoordinateAtIndex:i2 withCoordinate:coord1];} ' – Larme
@Larmeそれは動作します。ありがとう – johnsonjp34