C++ インスタンスから Objective C クラスのインスタンスを作成しています。問題は、いくつかの変数 (obj c インスタンス内) の値を取得しようとすると、常に 0 になることです。一部の NSLog も無視されます!:
Objective 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 : public ofxiPhoneApp { public: void 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";
}
結果は常にFinishedですか?0、購入時に 1 に設定しても. また、NSLog(@"STORE: HELLO THERE"); 無視されます
何が起こっているのかわかりません