2012-07-21 36 views
3

我得到一个错误:编译错误MKStoreKit

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

当我在我的应用程序上的onComplete线实现MKStoreKit 4.3

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

回答

5

API you are trying to use有这样的方法:

// 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;   
} 
+0

感谢您的帮助,MKStoreKit似乎在一个非常糟糕的方式进行记录,代码我上面使用的是一位MKStoreKit作者在他们的博客上提出的建议! – XIII 2012-07-22 03:00:18

+0

@XIII,是的,他们可能在某些时候改变了API,并且从来不打扰更新博客:( – Nate 2012-07-22 03:04:45

3

答案新API

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