2011-07-12 31 views
0

將一堆整數值存儲到NSDictionary中可以保存爲plist的過程涉及哪些過程?要存儲在plist中的字典中的整數值

然後,如何將plist讀回到NSDictionary中,然後獲取它們的值?

我想存儲一堆值,然後在應用程序重新啓動時讀取它們。

回答

0

,用於存儲在字典整數值---

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

現在保存上述整數值STR到字典as--

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