XCode错误"二进制表达式的操作数无效"

Piy*_*iyo 8 iphone ios5 xcode4.3

我有一个NSTimeInterval存储为double.我想使用%运算符获得第二个值的分钟数.

int remainingSeconds = scratch % 60;
Run Code Online (Sandbox Code Playgroud)

错误表示"二进制表达式的无效操作数"指向%Help请.

Oma*_*ith 21

模数用于整数,因此要使代码工作,请执行以下操作

int remainingSeconds = (int)scratch % 60;
Run Code Online (Sandbox Code Playgroud)

要在浮点数上使用模数,请使用fmod

int remainingSeconds = fmod(scratch, 60);
Run Code Online (Sandbox Code Playgroud)

在这里查看答案如何在objective-c/cocoa touch中进行模运算?