我正在從C++實例創建Objective C類的實例。問題是,當試圖得到一些瓦爾的值(obj的Ç實例)我總是得到0一些NSLogs也被忽略!:從C++類調用變量到Objective C類
目標C類: InAppPurchaseManager.h
@interface InAppPurchaseManager : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>{
SKProduct *proUpgradeProduct;
SKProductsRequest *productsRequest;
@public
int finishedPurchaseProcess;
}
- (int)hasFinishedPurchaseProcess;
- (void)purchase;
@end
InAppPurchaseManager.m
@implementation InAppPurchaseManager
- (void)purchase{
finishedPurchaseProcess=1;
}
- (int)hasFinishedPurchaseProcess{
NSLog(@"STORE: HELLO THERE");
return finishedPurchaseProcess;
}
testApp.h 類testApp:公共ofxiPhoneApp { 公共: 空隙goToStoreFromMenu(); void checkPurchase();InAppPurchaseManager * theStore; }
testApp.mm
// First I call ghis function
void testApp::goToStoreFromMenu(){
InAppPurchaseManager* theStore = [[InAppPurchaseManager alloc] init];
[theStore purchase];
}
// And then this function
void testApp::checkPurchase(){
cout << "Finished? " << [theStore hasFinishedPurchaseProcess] << "\n";
}
,結果總是完成了嗎? 0,即使我在購買中將其設置爲1。另外還有NSLog(@「STORE:HELLO THERE」);被忽略
我不明白這是怎麼回事
你試過調試你的應用程序嗎?調試時是否達到NSLog(...)? – Andrew 2011-03-13 20:15:01
您是否嘗試去除'testApp :: goToStoreFromMenu'中的'InAppPurchaseManager *'? – kennytm 2011-03-13 20:22:25