【发布时间】:2018-03-01 16:21:51
【问题描述】:
我正在尝试解决countOfBytesReceived / countOfBytesExpectedToReceive,但它要么返回0.000000,要么返回1.000000。
我对@987654325@ 和countOfBytesExpectedToReceive 都进行了NSLog,我可以看到countOfBytesExpectedToReceive 与预期相同,而countOfBytesReceived 发生了变化。
CGFloat progressRatio = [task countOfBytesReceived] / [task countOfBytesExpectedToReceive];
[progressView setProgress:progressRatio];
NSLog(@"%lld", [task countOfBytesReceived]);
NSLog(@"%lld", [task countOfBytesExpectedToReceive]);
NSLog(@"%f)", progressRatio);
但 progressRatio 总是返回 0.000000 或 1.000000,而不应返回。
我在 scheduledTimerWithTimeInterval 中有这段代码,所以它确实每 0.01 运行一次。
我做错了什么?
【问题讨论】:
标签: ios objective-c integer-division