Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflicting return type in implementation of 'supportedInterfaceOrientations': - Warning

After upgrading to Xcode 7.0 I get a warning in the UIViewControllerRotation method: - (NSUInteger)supportedInterfaceOrientations:

Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned int')

Why is that, and how do I fix it?

EDIT: If you go to the definition you'll see that the return type acctually has changed: - (UIInterfaceOrientationMask)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0); but changing the return type in the code doesn't silence the warning.

like image 957
turingtested Avatar asked Sep 21 '15 15:09

turingtested


2 Answers

Try this tweak:

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000  
- (NSUInteger)supportedInterfaceOrientations  
#else  
- (UIInterfaceOrientationMask)supportedInterfaceOrientations  
#endif  
{
   return UIInterfaceOrientationMaskPortrait;
}
like image 140
Nishant Avatar answered Nov 12 '22 22:11

Nishant


I am using this one:

#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_9_0
#define supportedInterfaceOrientationsReturnType NSUInteger
#else
#define supportedInterfaceOrientationsReturnType UIInterfaceOrientationMask
#endif

- (supportedInterfaceOrientationsReturnType)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

... a little bit longer than Nishant's fix but a little bit clearer, I think.

like image 34
turingtested Avatar answered Nov 12 '22 22:11

turingtested