3
我有一个NSURL委托方法这需要在NSInteger的作为参数的委托方法
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
NSInteger的是一份署名长更改参数类型的范围为-2147483647到2147483647。我的问题是,有时我我得到的数值超过了正数范围,这导致数值变成了我不想要的负数。
所以我改变了NSInteger的到NSUInteger
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSUInteger)bytesWritten totalBytesWritten:(NSUInteger)totalBytesWritten totalBytesExpectedToWrite:(NSUInteger)totalBytesExpectedToWrite
我的问题是,它是否是确定做出这样的改变?到目前为止我还没有任何问题,该方法正在调用,我正在得到预期的结果。
我担心可能发生的一些不可预见的问题。
你怎么能得到超出范围的价值?您真的在单个写入块中发送了2GB以上的数据? – rmaddy 2013-03-04 19:52:56
totalBytesExpectedToWrite有时会超过2 GB – user1861763 2013-03-04 19:54:47
对不起,我没有足够的滚动。我只查看了'bytesWritten'参数。 – rmaddy 2013-03-04 19:57:10