Search code examples
iosios7appstore-approvaliphone-privateapi

Why pitchEnabled is considered as a private API?


Xcode failed to validate my app because

This app references to non-public selectors in Payload/...: pitchEnabled

#ifdef __IPHONE_7_0
if ([mapView respondsToSelector:@selector(pitchEnabled)]) {
    mapView.pitchEnabled = NO;
    mapView.rotateEnabled = NO;
}
#endif

Replacing selector(pitchEnabled) with NSSelectorFromString(@"pitchEnabled") solved this issue but makes me feel dirty, why pitchEnabled is considered as private API and what is the best approach to avoid this situation?


Solution

  • Because you are check for a method and not the property. And the getter method is isPitchEnabled not pitchEnabled.

    // Rotate and pitch are enabled by default on Mac OS X and on iOS 7.0 and later.
    @property (nonatomic, getter=isRotateEnabled) BOOL rotateEnabled NS_AVAILABLE(10_9, 7_0);
    @property (nonatomic, getter=isPitchEnabled) BOOL pitchEnabled NS_AVAILABLE(10_9, 7_0);