本文介绍了将NSInteger转换为NSUInteger?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将NSInteger转换为NSUInteger,我在Google上进行了搜索,但没有找到真正的答案.我该怎么办?
I am trying to convert a NSInteger to a NSUInteger and I googled it and found no real answer. How would I do this?
推荐答案
NSInteger
和NSUInteger
只是原始整数类型的typedef:
NSInteger
and NSUInteger
are just typedefs for primitive integer types:
#if __LP64__ || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
因此,您无需在它们之间转换".一个简单的转换就足够了.喜欢:
As such, you don't need to "convert" between them. A simple cast should be sufficient. Like:
NSInteger myInt = 0;
NSUInteger unsignedInt = (NSUInteger)myInt;
这篇关于将NSInteger转换为NSUInteger?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!