Frage

I'm still struggling with MKStoreKit.

There is a button called "buyAction" who has to launch the in-app purchase process. I've tried to implement it following tutorial advice but it still doesn't work :

- (IBAction)buyAction:(id)sender {
NSLog(@"buyFeature")
[[MKStoreManager sharedManager] buyFeature:@"PBonnet.TOEIC3.Package1"
                                onComplete:^(NSString* purchasedFeature, NSData*purchasedReceipt, NSArray* availableDownloads)
 { package1bought=1;
     NSLog(@"success");

 }
                               onCancelled:^
 { NSLog(@"failed purchase");

 }]; 

}

On the onCompleteline, I've got 2 error messages : "Parameter name omitted" and "Expected expression".

Thanks for your help.

Cheers

EDIT of the onComplete line as supposed by matt. Now, the log is showing "buyFeature" but nothing after. App Store doesn't launch. Log shows this error message :

NSUbiquitousKeyValueStore error: PBonnet.TOEIC3 has no valid com.apple.developer.ubiquity-kvstore-identifier entitlement.

War es hilfreich?

Lösung

Look at the header for MKStoreManager. Here is the declaration for buyFeature:onComplete:onCancelled:

- (void) buyFeature:(NSString*) featureId
         onComplete:(void (^)(NSString* purchasedFeature, NSData*purchasedReceipt, NSArray* availableDownloads)) completionBlock
        onCancelled:(void (^)(void)) cancelBlock;

So, just to start with, we see that onComplete: requires a block that takes three parameters. But you are supplying a block with no parameters. Thus, the compiler rightly complains that you forgot the block parameters.

In effect, the problem has nothing whatever to do with MKStoreKit. The problem is that you don't know C - in particular, you don't know the syntax for blocks. I would suggest reading Apple's explanation of this topic.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top