我正在为 IAP 使用RMStore库(基于订阅),但在这一行出现异常: [[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
- (void)viewDidLoad
{
[super viewDidLoad];
_products = @[@"NEWSUB01",
@"NEWSUB06",
@"NEWSUB12"];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[[RMStore defaultStore] requestProducts:[NSSet setWithArray:_products] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
_productsRequestFinished = YES;
} failure:^(NSError *error) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Products Request Failed", @"")
message:error.localizedDescription
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"")
otherButtonTitles:nil];
[alertView show];
}];
}
下面是 requestProducts 函数,异常在行:[_productsRequestDelegates addObject:delegate];
- (void)requestProducts:(NSSet*)identifiers
success:(RMSKProductsRequestSuccessBlock)successBlock
failure:(RMSKProductsRequestFailureBlock)failureBlock
{
RMProductsRequestDelegate *delegate = [[RMProductsRequestDelegate alloc] init];
delegate.store = self;
delegate.successBlock = successBlock;
delegate.failureBlock = failureBlock;
[_productsRequestDelegates addObject:delegate];
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
productsRequest.delegate = delegate;
[productsRequest start];
}
相同的代码适用于示例应用程序,但不适用于我的应用程序。