我正在使用此方法验证我的产品: - 为了获得产品数组,我首先解析从服务器下载的XML文件, 并获得产品列表,但ID始终无效。
- (void) validateProductsIdentifiers:(NSArray *) products {
NSMutableArray *productsIds = [[NSMutableArray alloc] init];
if (products != nil) {
for (EJBookInStore * book in products) {
//for each book, save the book id
[productsIds addObject:[book idBook]];
}
//Verify if the array is not empty
if ([productsIds count] > 0) {
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productsIds]];
productsRequest.delegate = self;
[productsRequest start];
}
} else {
NSLog(@"Erro...");
}
当我直接在方法中输入id时,id为validate:
- (void) validateProductsIdentifiers:(NSArray *) products {
NSMutableArray *productsIds = [[NSMutableArray alloc] init];
if (products != nil) {
for (EJBookInStore * book in products) {
//for each book, save the book id
[productsIds addObject:[book idBook]];
}
//Verify if the array is not empty
if ([productsIds count] > 0) {
//When i set the id like this, the id is validated
NSArray *prodIds = [NSArray arrayWithObjects:@"com.example.bookA", nil];
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray: prodIds]];
productsRequest.delegate = self;
[productsRequest start];
}
} else {
NSLog(@"Error...");
}
}