Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HappyDungcicle

macrumors newbie
Original poster
Sep 27, 2010
3
0
Hello,


I am HappyDungcicle. Happy Dungcicle is confused. How does Happy Dungcicle find an easy way to add text to the end (or to the middle) of a text file? Happy Dungcicle keeps his/her/its text file in the "MainBundle" (I think?). Here is the code I have that works that reads and displays the text file:
Code:
- (void)viewDidLoad {
    [super viewDidLoad];
	
	NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Tacos"ofType:@"txt"];
	
	if (filePath)
	{
		NSString *textFromFile = [NSString stringWithContentsOfFile:filePath];
		
		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Help Message"
														message:textFromFile
													   delegate:self
											  cancelButtonTitle:@"OK"
											  otherButtonTitles: nil];
		[alert show];
		[alert release];
		
	}
}


Happy Dungcicle would like to be able to add text to the end of this text file, without erasing the text that is already there. How does Happy Dungcicle do this? Happy Dungcicle is good at programming other languages but not Iphone. So precise code would be very helpful.
 
Then it sounds like Happy Dungcicle will be forced to read and write data from the documents folder. Happy Dungcicle wonders if there is a way to add text files directly to an app's documents folder rather than being forced to add such text files programmaticlly?

Thanks, Happy Dungcicle
 
Happy Dungcicle wonders if there is a way to add text files directly to an app's documents folder rather than being forced to add such text files programmaticlly?
There isn't. But depending on what you are using this text file for (say, for example, a data store), there may be other approaches you can consider. So, if you elaborated on your needs / uses for the info contained in the file, hopefully we can provide better advice.

P.S. Please refrain from referring to yourself in the third person. It just makes you sound either pretentious or like a house-elf.
 
P.S. Please refrain from referring to yourself in the third person. It just makes you sound either pretentious or like a house-elf.

While I appreciate the answers I have gotten, I have a better idea. How about if Happy Dungcicle talks in the third person if Happy Dungcicle wants to? When someone tries to control the way Happy Dungcicle expresses him/her/itself, Happy Dungcicle gets the idea that the person doing the suggesting is so insecure that they feel the need to go so far as to try to control the way other people ask questions. I would rather be pretentious than a control-freak. :apple:

Thanks! Happy Dungcicle.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.