2016-04-27

supportedInterfaceOrientations で警告

Xcode 7.0 より、iOS 9 向けにビルドすると supportedInterfaceOrientations で警告が出ます。
Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned long')

iOS 9 以降は、戻り値の型を変更します。
- (NSUInteger)supportedInterfaceOrientations
    
- (UIInterfaceOrientationMask)supportedInterfaceOrientations

iOS 9 未満をサポートする場合、処理を分けると便利です。
  1. #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
  2. - (NSUInteger)supportedInterfaceOrientations
  3. #else
  4. - (UIInterfaceOrientationMask)supportedInterfaceOrientations
  5. #endif
  6. {
  7.    return UIInterfaceOrientationMaskPortrait;
  8. }

参考