我想保存在文本文件中我的應用程序數據文件夾 我使用下面的方法來存儲,但它存儲單個字符串我想,我的數據是在數組怎麼可能陣列中的所有內容存儲在文本文件中保存數據從iPhone應用程序在iPhone應用程序的文本文件
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString*[email protected]"This is working fine";
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"file.txt"];
NSString *stringWithoutSpaces = [yourString stringByReplacingOccurrencesOfString:@" " withString:@""];
[stringWithoutSpaces writeToFile:filePath atomically:TRUE encoding:NSUTF8StringEncoding error:NULL];
我的數組就像下面
DataController *coffeeObj = [appDelegate.coffeeArray objectAtIndex:indexPath.row];
cell.resturantLocationLabel.text=coffeeObj.resturantLocation;
cell.foodQualityRatingLabel.text=coffeeObj.foodQualityRating;
cell.foodPresentationRatingLabel.text=coffeeObj.foodPresentationRating;
cell.waiterRatingLabel.text=coffeeObj.waiterRating;
cell.ambienceRatingLabel.text=coffeeObj.ambienceRating;
cell.overallRatingLabel.text=coffeeObj.overallRating;
cell.commentsLabel.text=coffeeObj.comments;
cell.emailAddressLabel.text=coffeeObj.emailAddress;
cell.addtoMailingListLabel.text=coffeeObj.addtoMailingList;
NSString*test=coffeeObj.comments;
什麼是數組數據?我們可以有樣品嗎? – 2012-07-09 06:17:49