Tag: 读写

如何读取/写入iOS中的文件,在模拟器以及设备上?

由于我需要在启动应用程序时读取文件,并在使用时有时会写入文件,因此我试图通过以下方法实现: NSString *dataFile = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"txt"]; NSLog(@"%@",dataFile); 而该文件应该在我的项目文件夹中,而不是在模拟器文件夹中: 2012-06-13 17:36:56.398 MyFileApp [610:15203] / Users / Rob / Library / Application Support / iPhone Simulator / 5.1 / Applications / 1FFD4436-DCCA-4280-9E47-F6474BEE0183 / MyFileApp.app / myFile.txt 所以如果我想使用模拟器以及真实设备来读/写,我该怎么办? 感谢您的build议

从plist获取数据到NSMutableArray并将NSMutableArray写入同一个plist iPhone

使用这段代码,我试图从Templates.plist文件中获取数据,但是我在数组中得到了空值。 //from plist NSString *path = [[NSBundle mainBundle] pathForResource:@"Templates" ofType:@"plist"]; NSMutableArray *arry=[[NSMutableArray alloc]initWithContentsOfFile:path]; NSLog(@"arrayArray:::: %@", arry); 这是我的plist文件: 另外我想知道如何添加更多的string到这个plist文件,并从这个plist中删除一个string。