• 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 Constants the solution
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

String Constants the solution


  • Subject: String Constants the solution
  • From: Prime Coderama <email@hidden>
  • Date: Fri, 09 Mar 2012 11:29:14 +1100

I have references to 'ground' and 'air' in multiple files. It is usually used in this context, but not always.
>   if ([transport.type isEqualToString:@"ground"]) {
>     // do something for automobiles
>   }
>   else if ([transport.type isEqualToString:@"air"]) {
>     // do something else for planes
>   }
>   else {
>     // we don't care
>   }

Should I be using string constants to represent 'ground' and 'air' so if I ever change their literal, I just update it in one place? e.g.
>   NSString * const TransportGround = @"ground";
>   NSString * const TransportAir = @"air";

I then decide I want to rename 'ground' to be 'wheels', then I would only update the above string constant.
_______________________________________________

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


  • Follow-Ups:
    • Re: String Constants the solution
      • From: Andreas Grosam <email@hidden>
    • Re: String Constants the solution
      • From: William Squires <email@hidden>
    • Re: String Constants the solution
      • From: Eeyore <email@hidden>
  • Prev by Date: Re: Accessing array in thread safe way
  • Next by Date: Re: @-directives
  • Previous by thread: Re: @-directives
  • Next by thread: Re: String Constants the solution
  • Index(es):
    • Date
    • Thread