2

I try to multiply two NSIntegers, but Xcode gives me an error:

NSInteger singlePage = ((NSInteger)floor((scrollView.contentOffset.x * 2.0f + pageWidth) / (pageWidth * 2.0f)));
NSInteger page = singlePage * visiblePages;  

And the error itself:

Invalid operands to binary expression ('NSInteger' (aka 'int') and 'NSInteger *' (aka 'int *'))  

NSInteger visiblePages is already defined and is being passed to a method.
I think that the compiler thinks that the * is a pointer sign and not a multiplication symbol. Is there any other method to multiply two NSIntegers?

Wyetro
  • 8,439
  • 9
  • 46
  • 64
Richard Topchii
  • 7,075
  • 8
  • 48
  • 115

1 Answers1

7

You defined visiblePages incorrectly. Replace

NSInteger *visiblePages;

with

NSInteger visiblePages;
Sviatoslav Yakymiv
  • 7,887
  • 2
  • 23
  • 43