1

enter image description here

The above SO answer is from here.

My question is :

The suggested code seems to be working as expected. But the problem is Xcode issues a warning against the statement pointed to by the red arrow. The warning is :

Instance method '-scrollViewDidScroll' not found (return type defaults to 'id')

Another issue is '-scrollViewDidScroll' returns "void" and not as 'id' which the compiler assumes.

Wish to get rid of the warning and let the compiler know that the return type is "void".

Hope that somebody could help ...

Community
  • 1
  • 1
Stanley
  • 4,446
  • 7
  • 30
  • 48

4 Answers4

5

self.delegate should be declared as a id<UIScrollViewDelegate> instance.

PatrickNLT
  • 4,075
  • 1
  • 25
  • 32
  • Thanks for your kind assistance... The declaration is : @interface Web_View_Delegate : UIViewController :) – Stanley May 21 '13 at 15:28
2

Make sure that the type of the delegate has the public method -scrollViewDidScroll.

Cthutu
  • 8,713
  • 7
  • 33
  • 49
1

Explicit casting probably can solve this problem for you.

Vytautas
  • 573
  • 3
  • 8
-3

I ran into a similar situation where I was calling a selector on a callback that is set programmatically. It generated a warning since the compiler (correctly) assumed it could not tell if the selector was valid for that object at compile time. I used the following code pattern to suppress the warning, which should also work in your case.

//Suppress compiler warnings
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

//Perform method that generates warning
[self.delegate scrollViewDidScroll: scrollView];

//Stop suppressing compiler warnings
#pragma clang diagnostic pop
Matt F.
  • 137
  • 1
  • 1
  • 5