Adding iOS availability check to IBOutlet in Objective-C

Viewed 94

I'm adding Sign in with Apple to my app and am aware that it's only supported in iOS 13 and up while I still support back to iOS 11.

I want to add the button via Storyboards as that's what I'm using. When I add the button:

@property (weak, nonatomic) IBOutlet ASAuthorizationAppleIDButton *signInWithAppleButton;

I get the following warning:

enter image description here

as you would expect.

The fix-it adds an API_AVAILABLE macro just above my interface declaration, so it now looks like this:

API_AVAILABLE(ios(13.0))
@interface SignUpViewController ()

// .. bunch of IBOutlets
@property (weak, nonatomic) IBOutlet ASAuthorizationAppleIDButton *signInWithAppleButton;

@end

My question is: is this correct? The app still runs perfectly fine on iOS 12, and I can just hide the button if it's running anything lower than iOS 13, but I just find it strange that the fix it is applied to the whole interface instead of just to the IBOutlet somehow.

Any info appreciated.

0 Answers
Related