// --------------------------------------------------------------------
我正在构建一个iPhone应用程序,并使用Openfeint SDK/Library/Framework(??)这是用C++编写的。
我试着创建一个单例,希望能在正常情况下包含它的头。m文件,但这不起作用,我仍然需要创建包含头的文件。嗯
这是我创造的单身汉。。。
// --------------------------------------------------------------------
// OpenfeintController.h
// --------------------------------------------------------------------
#import <Foundation/Foundation.h>
@interface OpenfeintController : NSObject {
NSString *productKey, *secretKey, *displayName;
}
+(OpenfeintController*)sharedOpenfeintController;
- (void) initializeWithProductKey:(NSString *)pKey andSecretKey:(NSString *)sKey andDisplayName:dName;
- (void) launchOpenFeint;
- (void) submitHighScoreToLeaderboard:(NSString *)leaderboardId;
@end
实施
// --------------------------------------------------------------------
// OpenfeintController.mm
// --------------------------------------------------------------------
#import "OpenfeintController.h"
#import "OpenFeint.h"
static OpenfeintController *singletonOpenfeintController = nil;
@implementation OpenfeintController
+(OpenfeintController*)sharedOpenfeintController {
@synchronized(self) {
if (!singletonOpenfeintController) {
singletonOpenfeintController = [[OpenfeintController alloc] init];
}
}
return singletonOpenfeintController;
}
- (void) initializeWithProductKey:(NSString *)pKey andSecretKey:(NSString *)sKey andDisplayName:dName
{
//[OpenFeint initializeWithProductKey:pKey andSecret:sKey andDisplayName:dName andSettings:nil andDelegates:nil];
}
- (void) launchOpenFeint
{
}
- (void) submitHighScoreToLeaderboard:(NSString *)leaderboardId
{
}
@end