36
A
回答
29
在这种情况下,您可能右键单击并转到定义:
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
#else
typedef int NSInteger;
typedef unsigned int NSUInteger;
#endif
+0
ok thanx i得到它 – Hitarth
+0
容易和正确 –
20
的区别是抽象类型及其同伙从硬件大小。现在我们不必担心整数是多少,或者指针在特定硬件上有多大。
“C”在这方面不好,只能说明一个long至少和int一样大,int是硬件的“自然”整数大小(不管是什么意思),int是至少只要短 - 一个(大混乱)。
这似乎是来自Fortran的一个好主意,但并没有很好的老化。
可以使用POSIX定义的东西,比如uint32_t,int16_t等。但是这并不能解决指针在任何特定硬件上需要多大。
因此,如果Apple将返回类型定义为NSUInteger,那么您只需使用该类型,并且不需要知道它是否为特定硬件的大小为16,32或64位。 (我只是为了举例而选择了这些数值)。
正如你在@Bastian中看到的那样,实际尺寸取决于硬件。
该文档回答“问题的信”,但没有提供“为什么”的理解?
相关问题
- 1. CLI和GUI之间的NSInteger区别?
- 2. NSNotFound,NSInteger,NSUInteger和NSRange.location
- 3. int和NSInteger有什么区别?
- 4. uint和unsigned int之间的区别?
- 5. C#中char和int之间的区别#
- 6. Python 3.5 - '//'和'int()'之间的区别
- 7. int p = *(int *)i和int p = *(int *)&i之间的区别
- 8. int someInts [3]和int * someInts = new int [3]之间的区别?
- 9. 新的int和new(int)之间的C++有什么区别?
- 10. '(int)a','a as int'和C#中的Convert.ToInt32(a)之间的区别
- 11. foo(int * arr)和foo(int arr [])之间的任何区别?
- 12. int * p和int * p声明之间的区别
- 13. 最终静态int和静态最终int之间的区别?
- 14. int [] []和int [,]之间的区别是什么?
- 15. 返回值之间的区别int&和const int&
- 16. int fpurge()和int fflush()之间的区别C
- 17. C++中新int()和新int {}之间的区别
- 18. 传递(int x)和(const int x)之间的区别
- 19. “Convert.ToString(Nullable <int>)”和“Nullable <int> .ToString()”之间的区别?
- 20. NSUInteger vs NSInteger,int vs unsigned以及类似的情况
- 21. int(floatvar)和(int)floatvar之间是否有区别?
- 22. Java中的int a [5],int a [],int a [] = {2,3}之间的区别
- 23. '+ ='和'= +'之间的区别?
- 24. {!!之间的区别!!}和{{}}
- 25. ==和case之间的区别?
- 26. '#','%'和'$'之间的区别
- 27. | =和^ = css之间的区别
- 28. “%〜dp0”和“。\”之间的区别?
- 29. .eq之间的区别。和==
- 30. ==和.equals()之间的区别?
没有'NSInt'这样的东西。 – BoltClock
NSInteger非NSInt .. – Hitarth
[请参阅文档](http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html) – Jiri