这听起来像是一个愚蠢的问题,但我可以轻松地在网上找到任何解决方案。
如何在.h文件中声明NSString?
我已经尝试过这个:
@property (nonatomic, retain) NSString *DATABASE_NAME;
但我收到错误:
Expected member name or ';' after declaration
这里有什么问题吗?
编辑
我的头文件:
@interface GlobalVariables : NSObject
@property BOOL MAP_SATELLITE_VIEW;
@property (nonatomic, retain) NSString *DATABASE_NAME;
+ (GlobalVariables*)sharedInstance;
@end
最佳答案
您显示的代码没有任何问题,因此您必须查看其上下文。一些想法:
- 检查
#import
.h
文件的方式/位置。 - 检查
DATABASE_NAME
是否已在其他地方定义。 - 如果将此行替换为其他内容(例如:
@property (nonatomic, allocate) NSInteger dummyInt;
)或将其添加到该行上方,会发生什么情况?
关于ios - 在 .h 文件中声明 NSString - Objective c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49830067/