3

I'm getting an error:

Incompatible block pointer types sending 'void (^)(NSString *_strong)' to parameter of type 'void (^)(NSString *_strong, NSData *__strong)'

When I'm implementing MKStoreKit 4.3 in my app on the line of onComplete:

-(IBAction)purchaseFull {
    [[MKStoreManager sharedManager] buyFeature:@"productID"
                                onComplete:^(NSString* purchasedFeature)
    {
         NSLog(@"Purchased: %@", purchasedFeature);
         //purchaseBtn.hidden = YES;
    }
    onCancelled:^
    {
        NSLog(@"User Cancelled Transaction");
    }];
}
XIII
  • 2,036
  • 16
  • 25

2 Answers2

5

The API you are trying to use has a method like this:

// use this method to invoke a purchase
- (void) buyFeature: (NSString*) featureId         
         onComplete: (void (^)(NSString* purchasedFeature, 
                               NSData* purchasedReceipt)) completionBlock
        onCancelled: (void (^)(void)) cancelBlock;

but, for the completionBlock parameter, you're passing

^(NSString* purchasedFeature) {
      NSLog(@"Purchased: %@", purchasedFeature);             
      //purchaseBtn.hidden = YES;        
}

which means you are missing the second (NSData*) parameter.

Change your code to something like this:

^(NSString* purchasedFeature, NSData* purchasedReceipt) {
      NSLog(@"Purchased: %@", purchasedFeature);             
      //purchaseBtn.hidden = YES;        
}
Nate
  • 31,017
  • 13
  • 83
  • 207
  • Thanks for your help, MKStoreKit seems to be documented in a very bad way, the code I used above was the one MKStoreKit author suggested on their blog! – XIII Jul 22 '12 at 03:00
  • @XIII, yeah they probably changed the API at some point, and never bothered to update the blog :( – Nate Jul 22 '12 at 03:04
3

the answer for the new API:

 [[MKStoreManager sharedManager]
 buyFeature:kFeatureAId
 onComplete:^(NSString* purchasedFeature, NSData*purchasedReceipt, NSArray* availableDownloads)
 {
       NSLog(@"Purchased: %@", purchasedFeature);
 }
 onCancelled:^
 {
     NSLog(@"User Cancelled Transaction");
 }
 ];
Samidjo
  • 2,315
  • 30
  • 37