Re: Core Data/Cocoa Bindings: best practice for using strings in code?
Re: Core Data/Cocoa Bindings: best practice for using strings in code?
- Subject: Re: Core Data/Cocoa Bindings: best practice for using strings in code?
- From: Óscar Morales Vivó <email@hidden>
- Date: Wed, 13 Jul 2005 16:57:37 -0400
I think the usual recommendation is to use constant NSString objects.
Put them in the code file, and declare them as 'extern' in the header
file if you need to. Examples from my code:
In header OMVPerson.h:
extern NSString *OMVPersonParentsKey;
In code file OMVPerson.m:
NSString *OMVPersonParentsKey = @"parents";
But I reckon if someone came with a more scalable and/or easily
maintainable solution I'd like to hear about it.
Hope that helps.
On Jul 13, 2005, at 16:43 , Michael McCracken wrote:
Hi, using Core Data and Cocoa Bindings, I find that my code is lousy
with string constants for things like entity names and key paths. I've
already had one typo that wasn't immediately obvious, and that's
enough. I'm thinking about solving this by defining them all as cpp
macros, but that seems like a maintenance headache (although still an
improvement) as I experiment with the data model.
What have other developers found to be useful to enforce sanity here?
Thanks,
-mike
--
Michael McCracken
UCSD CSE PhD Candidate
http://www.cse.ucsd.edu/~mmccrack/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden