【问题标题】:Integer values in a dictionary to be stored in a plist要存储在 plist 中的字典中的整数值
【发布时间】:2011-07-12 09:21:18
【问题描述】:

将一堆整数值存储到可以保存为 plist 的 NSDictionary 中涉及哪些过程?

那么如何将该 plist 读回到 NSDictionary 中,然后获取它们的值?

我想存储一堆值,然后在应用重新启动时将它们读回。

【问题讨论】:

    标签: plist nsdictionary


    【解决方案1】:

    用于在字典中存储整数值---

    // saves integer as NSString.
    NSString *str = [NSString stringwithformat:@"%d", 234 (integer value)];
    

    现在将上述整数值 str 保存到字典中--

    // saves your integer value into dictionary..
    NSDictionary *dict = [[NSDictionary alloc] setObject:str forkey:@"intervalue"];
    

    从 NSDictionay 中检索整数值-----

    //got the value in string format
    NSString *str = [dict objectforkey:@"integervalue"];
    
    // from this we got the original integer value from the string...
    NSInteger integerValue = [str intValue];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-17
      • 2016-11-19
      相关资源
      最近更新 更多