简体   繁体   English

设置NSInteger的最大值

[英]Set maximum value of NSInteger

* Sorry if this has been posted before but I have been looking for 30 mins now and cant find anything * * 对不起,如果之前已发布,但我一直在寻找30分钟,但无法找到任何 *

Hi, I have an NSInteger called currentcoins and I want the coins maximum value to be 999. I have tried everything including 嗨,我有一个名为currentcoins的NSInteger,我希望硬币的最大值为999.我已经尝试了一切,包括

#undef NSIntegerMax
#define NSIntegerMax 999

but the NSInteger isn't taking any notice of this. 但NSInteger没有注意到这一点。 Has anyone got any solutions? 有没有人有任何解决方案? (I'm doing this for iOS) (我正在为iOS做这个)

Thanks in advance. 提前致谢。

You should never ever redefine a system define like NSIntegerMax . 您永远不应该重新定义像NSIntegerMax这样的系统定义。 This is set by the type of system you are building your app for (32 or 64 bit). 这是由您为(32或64位)构建应用程序的系统类型设置的。

Just define your own max like: 只需定义自己的最大值:

#define kMaxCoins 999

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM