Re: Store a file vs create on the fly?
Re: Store a file vs create on the fly?
- Subject: Re: Store a file vs create on the fly?
- From: Uli Kusterer <email@hidden>
- Date: Thu, 20 Jan 2011 11:21:18 +0100
On Jan 19, 2011, at 2:30 AM, Jeremy Matthews wrote:
> So I have a simple app which, in essence, creates a text file with some items determined by the user (kind of like an old-fashioned Mad Libs page). Most of the file does not change...I just change a few portions based upon checkbox states, textfield contents, etc. Question is: should I have that file pre-created within the app bundle, load it, make changes, and save out? Or, should I store the text in some strings within code and just write out the file when needed?
I usually do the former. Strings in code are awkward to edit (escaping line breaks and breaking strings onto multiple lines), so I usually just create a text file, put in some placeholder that I can search for and replace, then load the thing into an NSMutableString, search & replace, write it where it should end up.
Also, if you have comments or other localizable data in the template you can take advantage of the built-in localization facilities more easily.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden