我正在使用Singleton类,以下是代码:
.h文件:
#import <Foundation/Foundation.h>
@interface Credential : NSObject {
NSString *UID;
NSString *UPASS;
}
@property(nonatomic,retain) NSString *UID;
@property(nonatomic,retain) NSString *UPASS;
static Credential *credential = NULL;
+(Credential*) sharedInstance;
/*
+ @property(nonatomic,retain) NSString *UID;
+ @property(nonatomic,retain) NSString *UPASS;
*/
@end
.m文件:
#import "Credential.h"
@implementation Credential
@synthesize UID,UPASS;
-(void) dealloc{
[UID release];
[UPASS release];
[super dealloc];
}
+(Credential*) sharedInstance
{
@synchronized(self)
{
if (credential == NULL) {
credential = [[Credential alloc] init];
}
}
return credential;
}
@end
以下行产生警告“已定义但未使用”
static Credential *credential = NULL;
我无法弄清楚我一直在“sharedInstance”函数下的.m文件中使用凭证变量,那为什么我会收到此警告?
给我一个奇怪的问题!