gpt4 book ai didi

ios - 在 iOS 中存储字典数据的位置

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:15:56 25 4
gpt4 key购买 nike

我正在开发 iPhone 应用程序,我有一个疑问

我有一个 NSMutableDictionary 包含这种格式的数据

第 0 个索引处的字典:

"ProductId":"77386",
"ProductImage":"http://static.abcd.com/images/product/large/design_gallery_slide_green - Copy (2).jpg",
"Productshortname":"Apple iPhone 5c 16GB",
"categorycode":null,
"categoryid":8,
"categoryimage":"",
"categoryshortname":"",
"favorite":"0",
"price":"31500",
"productnameinUrl":"apple-iphone-5c-16gb",
"storecount":"10"

第一个索引处的字典:

    "ProductId":"11386",
"ProductImage":"http://static.abcd.com/images/product/large/design_gallery_slide_green - Copy (2).jpg",
"Productshortname":"Apple iPhone 5s 16GB",
"categorycode":null,
"categoryid":8,
"categoryimage":"",
"categoryshortname":"",
"favorite":"1",
"price":"31500",
"productnameinUrl":"apple-iphone-5s-16gb",
"storecount":"18"

第二个索引处的字典:

    "ProductId":"31386",
"ProductImage":"http://static.abcd.com/images/product/large/design_gallery_slide_green - Copy (2).jpg",
"Productshortname":"Apple iPhone 4s 16GB",
"categorycode":null,
"categoryid":8,
"categoryimage":"",
"categoryshortname":"",
"favorite":"1",
"price":"31500",
"productnameinUrl":"apple-iphone-4s-16gb",
"storecount":"38"

等等……

我想做的是,我想将这个字典索引存储在我目录中的某个位置,我想在一段时间后甚至在关闭并打开应用程序几次后获取它。

我应该在哪里存储这种数据?有存储这种数据的吗?

请提前帮助并感谢!!

最佳答案

你可以将数据存储在NSUserdefaults中,可以随时随地访问

yourdict;//Your NSDictionary Object That contains the data to store

[[NSUserDefaults standardUserDefaults] setObject:yourdict forKey:@"dict"];

[[NSUserDefaults standardUserDefaults] synchronize];

在检索数据时,

dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"dict"]; 

关于ios - 在 iOS 中存储字典数据的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24752059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com