我知道它可能是重复的,但是在将xcode更新到版本6之后,我得到了大约30个隐式转换在我的ios项目中丢失了整数精度警告.
第一个例子:
NSArray * stations = [self stationsJSON][KEY_ITEM_LIST];
int newSize = (stations.count + 1); // Implicit conversion loses Integer precision: 'unsigned long' to 'int'
Run Code Online (Sandbox Code Playgroud)
第二个例子:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
int index = indexPath.row / 2; // Implicit conversion loses Integer precision: 'long' to 'int'
...
}
Run Code Online (Sandbox Code Playgroud)
我知道警告意味着什么.使用NSInteger可以帮助避免此警告.
我不明白,为什么xcode 5中没有警告?为什么我改变线后没有警告
int index = indexPath.row / 2;
Run Code Online (Sandbox Code Playgroud)
至
int index = indexPath.row / 2i;
Run Code Online (Sandbox Code Playgroud)