小小小石头 2012-05-08
今天照猫画虎的用c++调用了一段oc代码,需要注意的一点是为了混编,.cpp文件后缀要改为.mm,其他的就按照oc跟c++语法使用就是了
//
// MKStoreForCpp.h
//
#ifndef SGR_MKStoreForCpp_h
#define SGR_MKStoreForCpp_h
class MKStoreForCpp {
public:
inline static MKStoreForCpp& instance()
{
static MKStoreForCpp mkStoreForCpp;
return mkStoreForCpp;
}
public:
void buyFeature(const char* feature);
};
#endif//
// MKStoreForCpp.mm
//
#include "MKStoreForCpp.h"
#include "MKStoreManager.h"
void MKStoreForCpp::buyFeature(const char* feature)
{
[[MKStoreManager sharedManager] buyFeature: [NSString stringWithUTF8String: feature]];
}