在NSDictionary中添加整数0作为键的值

时间:2015-05-01 02:51:01

标签: objective-c integer nsmutabledictionary null

我正在创建字典plotGraph = plot(time(time > time(count) - scrollWidth), data(time > time(count) - scrollWidth),... time(time > time(count) - scrollWidth), data2(time > time(count) - scrollWidth),... time(time > time(count) - scrollWidth),data3(time > time(count) - scrollWidth)); grid on; axis([time(count) - scrollWidth time(count) min max]); 并希望将0指定为有效的整数值,如下所示:NSMutableDictionary* parameters = [[NSMutableDictionary alloc] init];但由于parameters[@"size"] = 0;的值为0,我收到以下警告:nil/NULL

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

免责声明:我个人认为括号包装数字更容易阅读,尽管它是可选

NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];

parameters[@"size"] = @(0);
NSInteger sizeInt = [parameters[@"size"] integerValue];