Ios 更改委托方法的参数类型

Ios 更改委托方法的参数类型,ios,objective-c,delegates,nsinteger,nsuinteger,Ios,Objective C,Delegates,Nsinteger,Nsuinteger,我有一个NSURL委托方法,它将NSInteger作为参数 - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite NSInteger是有符号的长字符,其

我有一个NSURL委托方法,它将NSInteger作为参数

- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite 
NSInteger是有符号的长字符,其范围为-2147483647到2147483647。我的问题是,有时我得到的值超过了正范围,这会导致值变为负数,这是我不想要的

所以我把NSInteger改成了NSInteger

 - (void)connection:(NSURLConnection *)connection didSendBodyData:(NSUInteger)bytesWritten totalBytesWritten:(NSUInteger)totalBytesWritten totalBytesExpectedToWrite:(NSUInteger)totalBytesExpectedToWrite 
我的问题是做出这样的改变是否可以?到目前为止,我还没有遇到任何问题,正在调用该方法,我得到了预期的结果


我担心一些可能发生的不可预见的问题。

这样做很好。将
NSInteger
更改为
NSInteger
只执行普通的强制转换。但是,我会保留
NSInteger
作为方法参数,然后在方法实现开始时将其显式转换为
NSInteger

如何获得超出范围的值?你真的在一个写块中发送了超过2GB的数据吗?totalBytesExpectedToWrite有时超过2GB抱歉,我没有滚动足够的数据。我只查看了
bytesWrite
参数。