gpt4 book ai didi

iphone - 为什么在 iphone 应用程序中保存 NSArray 总是失败

转载 作者:行者123 更新时间:2023-11-28 19:12:28 24 4
gpt4 key购买 nike

我想保存 NSArray ,但是失败了,为什么?

 -(void)SaveDataAll:(NSMutableArray *)dataToSave:(NSString *)name
{
NSArray *array = [NSArray arrayWithArray:dataToSave];


// save path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);

if ([paths count] > 0)
{
// Array path
NSString *arrayPath = [[paths objectAtIndex:0]
stringByAppendingPathComponent:name];

NSLog(@"SaveDataAll array====%@",array);
NSLog(@"SaveDataAll dataToSave====%@",dataToSave);
// save array
[array writeToFile:arrayPath atomically:YES];

// getout
NSArray *arrayFromFile = [NSArray arrayWithContentsOfFile:arrayPath];

NSLog(@"SaveDataAll ====%@",arrayFromFile);
}
}

这是打印的数组。

2013-01-22 16:51:45.010 [49227:c07] SaveDataAll   array====(
"\U4ee5\U8272\U5217\U548c\U4f0a\U6717\Uff1a\U4e00\U500b\U611b\U60c5\U6545\U4e8b\Uff1f",
"\U53f2\U63d0\U82ac\Uff0e\U611b\U5ef8\U65af: \U4e00\U500b\U7236\U89aa\U8207\U5973\U5152\U7684\U9023\U7e6b\Uff0c\U4e00\U6b21\U4e00\U5f35\U7167\U7247",
"Molly Crockett \U8ac7\U5c0f\U5fc3\U300c\U795e\U7d93\U80e1\U8aaa\U300d",
"Maz Jobrani: \U7576\U4e00\U500b\U6c99\U70cf\U5730\U963f\U62c9\U4f2f\U4eba\U3001\U5370\U5ea6\U4eba\U3001\U548c\U4f0a\U6717\U4eba\U8d70\U9032\U5361\U9054\U7684\U9152\U5427....",
"Ellen 't Hoen: \U85e5\U7269\U5c08\U5229\U806f\U76df\Uff0c\U62ef\U6551\U751f\U547d",
"Nina Tandon\Uff1a \U7d44\U7e54\U5de5\U7a0b\U5b78\U662f\U91ab\U7642\U500b\U4eba\U5316\U7684\U9060\U666f?",
"\U5091\U592b\Uff0e\U53f2\U5bc6\U65af\Uff1a\U5f9e\U76e3\U7344\U5b78\U5230\U7684\U7d93\U5546\U4e4b\U9053",
"Bobby Ghosh: \U70ba\U4f55\U5168\U7403\U8056\U6230\U5df2\U7d93\U8f38\U4e86",
"\U4fdd\U7f85\U00b7\U5361\U8fea\U5c3c\Uff08Paolo Cardini\Uff09\Uff1a \U5225\U518d\U4e00\U5fc3\U591a\U7528\U4e86\Uff01\U8a66\U8a66\U5c08\U5fc3\U4e00\U81f4\U5427\Uff01",
"Munir Virani: \U6211\U5982\U4f55\U611b\U4e0a\U79bf\U9df9",
"\U73cd\U59ae\Uff0e\U96ea\U666e\Uff1a\U7834\U788e\U7684\U8eab\U9ad4\U4e0d\U4ee3\U8868\U7834\U788e\U7684\U4eba",
"Ernesto Sirolli: \U60f3\U8981\U5e6b\U52a9\U4eba\U55ce? \U9589\U4e0a\U5634\Uff0c\U7136\U5f8c\U807d\U5427!",
"14:57",
"03:38",
"11:18",
"07:11",
"11:16",
"06:19",
"05:00",
"16:31",
"02:52",
"06:41",
"18:57",
"17:09",
"14:57",
"03:38",
"11:18",
"07:11",
"11:16",
"06:19",
"05:00",
"16:31",
"02:52",
"06:41",
"18:57",
"17:09",
"<UIImage: 0x95075d0>",
"<UIImage: 0xa297da0>",
"<UIImage: 0xa29c480>",
"<UIImage: 0xa27bae0>",
"<UIImage: 0xa29b5c0>",
"<UIImage: 0x950c0d0>",
"<UIImage: 0xa29fcb0>",
"<UIImage: 0x950cee0>",
"<UIImage: 0xa2a0310>",
"<UIImage: 0x9509310>",
"<UIImage: 0x95509a0>",
"<UIImage: 0xa297fe0>",
"/talks/lang/zh-tw/israel_and_iran_a_love_story.html",
"/talks/lang/zh-tw/steven_addis_a_father_daughter_bond_one_photo_at_a_time.html",
"/talks/lang/zh-tw/molly_crockett_beware_neuro_bunk.html",
"/talks/lang/zh-tw/maz_jobrani_a_saudi_an_indian_and_an_iranian_walk_into_a_qatari_bar.html",
"/talks/lang/zh-tw/ellen_t_hoen_pool_medical_patents_save_lives.html",
"/talks/lang/zh-tw/nina_tandon_could_tissue_engineering_mean_personalized_medicine.html",
"/talks/lang/zh-tw/jeff_smith_lessons_in_business_from_prison.html",
"/talks/lang/zh-tw/bobby_ghosh_why_global_jihad_is_losing.html",
"/talks/lang/zh-tw/paolo_cardini_forget_multitasking_try_monotasking.html",
"/talks/lang/zh-tw/munir_virani_why_i_love_vultures.html",
"/talks/lang/zh-tw/janine_shepherd_a_broken_body_isn_t_a_broken_person.html",
"/talks/lang/zh-tw/ernesto_sirolli_want_to_help_someone_shut_up_and_listen.html"
)

但是 NSLog(@"SaveDataAll ====%@",arrayFromFile); arrayFromFile 总是 nil 吗?

最佳答案

数组中有 UIImage - 它们无法保存

关于iphone - 为什么在 iphone 应用程序中保存 NSArray 总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14454992/

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