2

In an earlier answer about external constants, the preferred answer says

"Constants.m should be added to your application/framework's target so that it is linked in to the final product."

I am using Xcode 4 and can't see how this is done. Can someone help me with this?

I'm trying to move my user interface constants to a single file so I can manage them from one place. (I'm not interested in using a singleton for this case.)


Based on the answer provided below, I was able to make this work. The .h and .m files are very simple:

Constants.h

#pragma mark - Calendar Settings
extern const CGSize _kTileSize;

Constants.m

#import "Constants.h"

#pragma mark - Calendar Settings
const CGSize _kTileSize = { 46.f, 44.f };

Note that there is no interface and no implementation, Since it is not a class. I did add the files as instructed in the answer, except I selected new file... objective c class. Then I deleted the interface and implementation sections.

Now that I have it working I will add more constants to the file.

Community
  • 1
  • 1
Jim
  • 5,940
  • 9
  • 44
  • 91

2 Answers2

3

Go as follow:

1.File

2.New

3.New file

4.Objective C file

Moshekoor
  • 50
  • 1
  • 4
0

File -> New -> New file -> Objective C file.

Andrea Bergia
  • 5,502
  • 1
  • 23
  • 38
  • I tried this, but I don't see that choice. I see "objective c class" as a choice. I may be more confused by this than I thought. I'll post my two files in my original question. – Jim Jul 31 '11 at 20:32
  • Your answer works. I didn't realize it until I found my real problem. It was a typo. For future reference, I'll post .h and .m files. Thanks. (And since you posted first, I will select your response as the correct one.) – Jim Jul 31 '11 at 20:37