Question

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?

Was it helpful?

Solution

You defined visiblePages incorrectly. Replace

NSInteger *visiblePages;

with

NSInteger visiblePages;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top