In my objective-c project, I have a protocol like this:
@protocol MyProtocol
-(id) get:(NSString *) key;
-(void) set:(NSString *) key withValue:(id) value;
-(NSValue *) getSize;
-(void) setSize:(NSValue *) value;
-(NSValue *) getBounds;
-(void) setBounds:(NSValue *) value;
@end
OBJC_EXPORT const NSString *MYPROTOCOL_SIZE;
OBJC_EXPORT const NSString *MYPROTOCOL_BOUNDS;
And basically, those specific methods (getSize
, getBounds
, setSize
, setBounds
) are supposed the value that is supposed to be stored in MYPROTOCOL_SIZE
and MYPROTOCOL_BOUNDS
, respectively.
However, I cannot find an effective way to set those constant strings, by concatenating the results of other methods, because it gives me the error: initializer element is not constant
when I try to set them directly. Is there a way I can guarantee that the objects will always be initialized. (e.g. in a classes load
method), without having to manually call code when my program runs?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…