Use NSInteger instead of int for 32/64 bit safety

Use `NSInteger` instead of the primitive int for better 32/64 bit compatibility. Also eliminates implicit conversions between `int`, `NSInteger`, and `NSUInteger`.
May as well just type this as NSInteger and avoid the cast below.