Added explicit casting to prevent compiler warnings on 64bit systems where NSInteger is not 'int'.