3

我收到一个错误:

不兼容的块指针类型将“void (^ )(NSString *_strong )”发送到“void (^)(NSString * _strong, NSData *__strong)”类型的参数

当我MKStoreKit 4.3在我的应用程序中实现 onComplete 行时:

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

2 回答 2

5

您尝试使用的API具有如下方法:

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

但是,对于completionBlock参数,您正在传递

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

这意味着您缺少第二个 ( NSData*) 参数。

将您的代码更改为以下内容:

^(NSString* purchasedFeature, NSData* purchasedReceipt) {
      NSLog(@"Purchased: %@", purchasedFeature);             
      //purchaseBtn.hidden = YES;        
}
于 2012-07-21T23:57:42.797 回答
3

API的答案:

 [[MKStoreManager sharedManager]
 buyFeature:kFeatureAId
 onComplete:^(NSString* purchasedFeature, NSData*purchasedReceipt, NSArray* availableDownloads)
 {
       NSLog(@"Purchased: %@", purchasedFeature);
 }
 onCancelled:^
 {
     NSLog(@"User Cancelled Transaction");
 }
 ];
于 2012-09-26T09:17:22.483 回答