slackhq / SlackTextViewController

⛔️**DEPRECATED** ⛔️ A drop-in UIViewController subclass with a growing text input view and other useful messaging features
https://slack.com/
MIT License
8.32k stars 1.08k forks source link

Compiler warning: Parameter of 'scrollViewShouldScrollToTop' has different optionality than expected by protocol 'UIScrollViewDelegate' #173

Closed tomaskraina closed 9 years ago

tomaskraina commented 9 years ago

Compiling SlackTextViewController, installed with CocoaPods, emits the following warning:

./MyApp/__ObjC.SLKTextViewController:292:14: Parameter of 'scrollViewShouldScrollToTop' has different optionality than expected by protocol 'UIScrollViewDelegate'

xcode warning screenshot

This warning is presented even though I don't override scrollViewShouldScrollToTop anywhere in my project.

Removing the following line from SLKTextViewController.h fixes the warning:

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView NS_REQUIRES_SUPER;
dzenbot commented 9 years ago

Which version of XCode and Base SDK are you using?

tomaskraina commented 9 years ago

Xcode 6.3.1, Base SDK 8.0

dzenbot commented 9 years ago

I wasn't able to repro since I only have Base SDK 8.1 and above, and all seems fine.

If you're using Swift, you should definitely upgrade to Swift 2.0, included in XCode 6.3 and use Base SDK 8.3.

tomaskraina commented 9 years ago

Sorry, that was incorrect. I'm using Base SDK 8.3 and Swift 1.2. Only deployment target is 8.0.

I'll try different settings to see if it will disappear or not.

dzenbot commented 9 years ago

Keep me posted.

blakeperdue commented 9 years ago

@tomaskraina What was the outcome of this? I'm seeing the same thing with XCode 6.3.1, Swift 1.2, and Base SDK 8.3.

Were you able to get rid of those warnings? Thanks.

hankbao commented 9 years ago

Got these two warnings also. I guess that they may relate to the NS_REQUIRES_SUPER attribute.

dzenbot commented 9 years ago

There is no equivalent of __attribute((objc_requires_super)) (a.k.a NS_REQUIRES_SUPER) in Swift. I'm not sure how to fix this, except for waiting for Swift 1.3 and hoping that this attributes is somehow added in a compatible way with Objective-C.

This is a friendly warning from what I can tell, and it shouldn't cause any issues. Although, if you don't like having useless warnings in your projects (like I do), simply fork the repo and remove the macro on those methods. Remember to still call for super in those methods, as it is important to assure a good functioning of the library.

It doesn't make much sense to remove it because of Swift limitations, while Objective-C users might still need the warning about requiring super in their implementations.