为什么会有NSInteger? [英] Why is there an NSInteger?
问题描述
如果 NSInteger
就像普通的int
一样,为什么它存在并且被称为NSInteger
的目的是什么?
If NSInteger
is just like a regular int
then why does it exist and what is its purpose in being called NSInteger
?
我是Mac OS X编程的新手,我们将为此提供报告.
I'm new to Mac OS X programming and we'll be having a report for this.
推荐答案
这是一种体系结构安全(64位和32位)类型,用于支持C的不同平台和实现.
It's an architecture-safe (64 vs 32 bit) type to support different platforms and implementations of C.
Apple建议无论如何都要对普通类型使用NSInteger
,我想是为了便于移植!
Apple recommends that you use NSInteger
over normal types anyway, I would assume for portability!
您可以在以下基本描述:
构建32位应用程序时, NSInteger是32位整数.一种 64位应用程序将NSInteger视为 一个64位整数.
When building 32-bit applications, NSInteger is a 32-bit integer. A 64-bit application treats NSInteger as a 64-bit integer.
这篇关于为什么会有NSInteger?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!