Converting string to int changes the value

后端 未结 2 1623
野趣味
野趣味 2020-12-22 05:05

I\'m trying to convert a string value I retrieved from an XML parser into an integer. Unfortunately, I\'m finding that the integer value is not reflecting the number in the

相关标签:
2条回答
  • 2020-12-22 05:23

    The number in the string is too large to be stored as an integer. The highest integer possible with 32 bits is 2.147.483.647. Try using a long.

    0 讨论(0)
  • 2020-12-22 05:45

    The number is much too large to fit in a 32 bit int. What you want to do is use a long instead:

    long maxTweetID = [[[_dataArray lastObject]tweetID]longValue];
    

    EDIT:

    You actually need to use long long in Objective-C:

    long long maxTweetID = [[[_dataArray lastObject]tweetID]longLongValue];
    
    0 讨论(0)
提交回复
热议问题