【发布时间】:2016-07-21 21:38:58
【问题描述】:
我有一些 Objective-C 代码:
@interface CustomInitializers:NSObject
{
NSString *classStr;
NSInteger classInt;
}
+ (id) init;
+ (id) initWithString: (NSString *) stringToSet;
+ (id) initWithInteger: (NSInteger) intToSet;
+ (id) initWithAll:(NSString *)stringToSet classInt:(NSInteger)intToSet;
- (NSInteger) getClassInt;
- (NSString *) getClassStr;
@end
当我实现这个类时,我通过在变量前加下划线来引用变量(例如 _classStr)。但是这样编译的时候会提示错误:
[file name]:[line number]:[character]: Usage of undeclared identifer "_randSen"
如何防止这种情况发生?
【问题讨论】:
标签: objective-c class variables methods