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: Conrad Shultz <email@hidden>
- Date: Thu, 20 Jan 2011 12:17:49 -0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 1/20/11 2:21 AM, Uli Kusterer wrote:
> 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.
I fully agree. Another consideration that might not apply now but could
at some point in the future is that if you ever have someone else work
on the text templates, that someone else will not have to be a
programmer if the templates are split out.
Think along the lines of web development: we have CSS and templating to
largely remove designers from touching code, which on balance probably
makes both designers and developers happier.
- --
Conrad Shultz
Synthetiq Solutions
www.synthetiqsolutions.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk04mG0ACgkQaOlrz5+0JdWZmQCfbEw0mYqouOow9kRdvHvzBdZJ
5q4AnjYpnD/AkVKy2L2daCNsVIAxL/Gq
=6B8r
-----END PGP SIGNATURE-----
_______________________________________________
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