Hi Tharindu.

I would create two files: Constants.h and Constants.m. Just like all C code, 
you put your declarations in the .h and the definitions in the .m. They are 
going to be very similar, except the .m defines the values, so it only happens 
once. This is very important if you want to be able to compare NSString 
constants using pointer equality. You then have all of your other code import 
Constants.h

--------- Constants.h ---------------
extern const int Foo;
extern const float Bar;
extern const NSString *Suction;

--------- Constants.m ---------------
const int Foo = 42;
const float Bar = 4.2;
const NSString *Suction = @"Ball";

-Kenny


On Nov 29, 2009, at 9:30 AM, Tharindu Madushanka wrote:

> Hi
> 
> When defining constants can I keep all important constants in one file and
> use it all over the application, rather defining same constant in several .m
> files. This might be a basic question, but just could not figure out how to
> do this.
> 
> Thank you
> Tharindu Madushanka
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/kenny_leung%40pobox.com
> 
> This email sent to kenny_le...@pobox.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to