Open Menu
Close Menu
Apple
Shopping Bag
Apple
Mac
iPad
iPhone
Watch
TV
Music
Support
Search apple.com
Shopping Bag
Lists
Open Menu
Close Menu
Terms and Conditions
Lists hosted on this site
Email the Postmaster
Tips for posting to public mailing lists
String Literals and KVC
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
]
String Literals and KVC
Subject
:
String Literals and KVC
From: Sanjay Samani <
email@hidden
>
Date: Sun, 11 Jun 2006 12:58:36 +0100
I'm using KVC / Core Data for the first time. Not surprisingly I'm often accessing attributes using the KVC valueForKey: message. From previous programming experience, I've always tried to avoid "String Literals" in my code, i.e., things like @"keyName", but rather I try to replace them with string constants declared once in my file and reused throughout. This ensures that I don't get bugs due to typos in stings and saves typing with code completion.
However with KVC its a bit of a trade off because:
- Without syntax highlighting of strings, I actually personally find the code to be less readable with string contsntants.
- Also the string constants names have to be name space clean, I end up with silly names like XYMyVariableKey which is even less readable.
- KVC keys are quite easy to debug cos you simply get a runtime error saying xyz object is not KVC compliant for key: garbledKey, so you don't get some of the issues you get with other string literals
As a result I've continued to use valueForKey:@"keyName" rather than valueForKey:XYMyVariableKey
However I was wondering what people's experience with this are when maintaining products further down the line, particularly if there are multiple developers on the project. I want to use a standard approach now which will ensure minimum hassle long term with maintenance.
I'm not keen to write custom accessors unless I need to have custom functionality, to avoid having to debug / unit test them. KVC whilst verbose generally works fine for me.
Thanks, Sanjay
___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider.
http://uk.docs.yahoo.com/nowyoucan.html
_______________________________________________
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
Follow-Ups
:
Re: String Literals and KVC
From:
Nir Soffer <email@hidden>
Prev by Date:
Apple Data Plotting Framework
Next by Date:
Re: String Literals and KVC
Previous by thread:
Re: Apple Data Plotting Framework
Next by thread:
Re: String Literals and KVC
Index(es):
Date
Thread