Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process constants #10

Open
sohocoke opened this issue Feb 21, 2011 · 1 comment
Open

process constants #10

sohocoke opened this issue Feb 21, 2011 · 1 comment

Comments

@sohocoke
Copy link
Owner

e.g. in .m:
NSString* const kDate = @"kDate";
NSString* const kSubject = @"kSubject";
NSString* const kAlarmOffset = @"kAlarmOffset";

should produce in .h:
extern NSString* const kDate;
extern NSString* const kSubject;
extern NSString* const kAlarmOffset;

@sohocoke
Copy link
Owner Author

implementation proposal:

in file-level annotation, introduce a new section 'constants' in MyClass.m:
/*@
#import xxx
...

 state:
 ...

 constants:
 NSString* kMyMagicString = @"hoho"
 NSString* kMyMagicStringWithDefault = "kMyMagicStringWithDefault"
 ...
*/
@implementation MyClass

Let this generate the header MyClass.h:
@interface MyClass : NSObject {
...
}
@EnD

// (OCHGEN) constants from class-level annotation
extern NSString const kMyMagicString;
extern NSString const kMyMagicStringWithDefault;

// (OCHGEN) constant implementation
#ifndef CONSTANTS_MyClass
    NSString* const kMyMagicString = @"hoho";
    NSString* const kMyMagicStringWithDefault = @"kMyMagicStringWithDefault";
    #define CONSTANTS_MyClass
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant