在 MapBox 的 Route-Me 中,我看到 iVars 是这样实现的:
@implementation RMMapView
{
BOOL _delegateHasBeforeMapMove;
BOOL _delegateHasAfterMapMove;
BOOL _delegateHasBeforeMapZoom;
BOOL _delegateHasAfterMapZoom;
BOOL _delegateHasMapViewRegionDidChange;
BOOL _delegateHasDoubleTapOnMap;
BOOL _delegateHasSingleTapOnMap;
BOOL _delegateHasSingleTapTwoFingersOnMap;
BOOL _delegateHasLongSingleTapOnMap;
BOOL _delegateHasTapOnAnnotation;
BOOL _delegateHasDoubleTapOnAnnotation;
BOOL _delegateHasTapOnLabelForAnnotation;
BOOL _delegateHasDoubleTapOnLabelForAnnotation;
BOOL _delegateHasShouldDragMarker;
BOOL _delegateHasDidDragMarker;
BOOL _delegateHasDidEndDragMarker;
BOOL _delegateHasLayerForAnnotation;
BOOL _delegateHasWillHideLayerForAnnotation;
BOOL _delegateHasDidHideLayerForAnnotation;
BOOL _constrainMovement;
RMProjectedRect _constrainingProjectedBounds;
float _lastZoom;
CGPoint _lastContentOffset, _accumulatedDelta;
BOOL _mapScrollViewIsZooming;
}
也就是说,它是在 .m 文件而不是 .h 文件中声明的。如果我对这个 RMMapView 进行子类化,我看不到这些 iVar。有没有办法让它在子类中可见而不对世界可见?
我打算保留原始代码,因此选择子类化并从那里修改行为。但也许只是直接更改文件并通过 git 从主存储库更新代码是更好的方法吗?