javascript
c json保存整型数组,您如何存储“ int”? NSMutableArray *或NSMutableDictionary *中的值?整数形式的JSON数据的长期问题。...
How do you store "int" values in an NSMutableArray or NSMutableDictionary? Chronic problems with JSON data that come in as integers.
Should I try to store these integers as NSNumber objects or just as strings that contain the integer?
How dangerous is it to do a "raw" (int) conversion on the pointers if I know the values will always be Natural Numbers (numbers>=0 including zero for null.)
The integers I'm always working with are Foreign Key Id's from a database.
解決方案
Use NSNumber like this:
int yourInt = 5;
[myMutableArray addObject:[NSNumber numberWithInt:yourInt]];
Or using modern Objective C syntax, you can use the following for expressions:
[myMutableArray addObject:@(2 + 3)];
Or for lone numbers:
[myMutableArray addObject:@5];
總結(jié)
以上是生活随笔為你收集整理的c json保存整型数组,您如何存储“ int”? NSMutableArray *或NSMutableDictionary *中的值?整数形式的JSON数据的长期问题。...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: _不懂操作?手把手教你如何在linux下
- 下一篇: 更改Ubuntu终端复制和粘贴的快捷键