如何在没有数据库的情况下将数据保存到数组中
Posted
技术标签:
【中文标题】如何在没有数据库的情况下将数据保存到数组中【英文标题】:How to save a data in to array without DB 【发布时间】:2012-08-17 04:02:42 【问题描述】:如何将新添加的值保存到 NSMuttable 数组中,我想通过单击按钮重置新添加的项数组?谁能帮助我?
【问题讨论】:
【参考方案1】:通过以下方式添加它
array = [nsmutablearray arraywithcontentsoffile:path];
nsstring *item= @"string";
[array addObject:item];
[array writeToFile:path atomically:YES];
用不同的方法删除它:
[array removeObjectAtIndex:1];
或
[[NSFileManager defaultManager]removeItemAtPath:Path error:nil];
【讨论】:
以上是关于如何在没有数据库的情况下将数据保存到数组中的主要内容,如果未能解决你的问题,请参考以下文章