so I need to divide on variable by a number.
How can I do this?
I know about the C functions of DIV and MOD, but do not know how to use them in objective-C/cocoa-touch.
Heres an example of my code.
// hide the previous view
scrollView.hidden = YES;
//add the new view
scrollViewTwo.hidden = NO;
NSUInteger across;
int i;
NSUInteger *arrayCount;
// I need to take arrayCount divided by three and get the remainder
When I try to use / or % I get the error
“Invalid operands to binary expression (‘NSUInteger and int)
Thanks for any help
Firstly, should
arrayCountreally be a pointer?Anyway, if
arrayCountshould be a pointer, you just need to dereference it…… and use the operators
/(for division) and%(for getting the module):You can do it without the auxiliary variable too:
And just remove the dereference operator
*ifarrayCountis not a pointer: