【问题标题】:Set maximum value of NSInteger设置 NSInteger 的最大值
【发布时间】:2013-08-13 09:08:50
【问题描述】:

*对不起,如果之前已经发布过,但我现在一直在寻找 30 分钟,但找不到任何东西*

嗨,我有一个名为 currentcoins 的 NSInteger,我希望硬币的最大值为 999。我已经尝试了所有方法,包括

#undef NSIntegerMax
#define NSIntegerMax 999

但是 NSInteger 没有注意到这一点。 有没有人有任何解决方案? (我正在为 iOS 做这个)

提前致谢。

【问题讨论】:

    标签: iphone xcode ipad max nsinteger


    【解决方案1】:

    您永远不应该重新定义像NSIntegerMax 这样的系统定义。 这是由您构建应用程序的系统类型(32 位或 64 位)设置的。

    只需定义您自己的最大值,例如:

    #define kMaxCoins 999
    

    【讨论】:

    • 我已经定义了这个但是 NSInteger 仍然高于 999
    • 哦,我还没有办理登机手续。对不起,我有点厚了一些东西
    • 好的 if (currentcoins < 90) { currentcoins = currentcoins + 1; } 我有 90 个用于测试目的
    猜你喜欢
    • 2011-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-20
    • 2015-01-19
    • 2016-04-07
    • 1970-01-01
    • 2019-07-09
    相关资源
    最近更新 更多