要存储在plist中的字典中的整数值

时间:2011-07-12 09:21:18

标签: plist nsdictionary

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

那么如何阅读那个plist回到NSDictionary,然后得到它们的值?

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

1 个答案:

答案 0 :(得分:0)

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

// 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];