Jim
Jim

Reputation: 5960

Linking External Constants -- Objective C

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.

Upvotes: 2

Views: 853

Answers (2)

Moshekoor
Moshekoor

Reputation: 60

Go as follow:

1.File

2.New

3.New file

4.Objective C file

Upvotes: 3

Andrea Bergia
Andrea Bergia

Reputation: 5542

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

Upvotes: 0

Related Questions