如何按价格在产品购买中对产品进行分类?

jea*_*ean 2 iphone objective-c in-app-purchase ios

首先,我从IAP获得了一些产品

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response  
{  
    [productDetailsList addObjectsFromArray: response.products];  
    [productDisplayTableView reloadData];  
}
Run Code Online (Sandbox Code Playgroud)

如何按产品价格将它们放入uitableview中?谢谢.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  
{  
    static NSString *GenericTableIdentifier = @"GenericTableIdentifier";  
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: GenericTableIdentifier];  
    if (cell == nil) {  
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                       reuseIdentifier:GenericTableIdentifier] autorelease];
    }   

    SKProduct *thisProduct = [productDetailsList objectAtIndex:row];
    NSUInteger row = [indexPath row];

    [button setTitle:localizedMoneyString forState:UIControlStateNormal];

    [cell.contentView addSubview:button];

    return cell; 
}
Run Code Online (Sandbox Code Playgroud)

ddi*_*ego 14

NSArray *products = [response.products sortedArrayUsingComparator:^(id a, id b) {
        NSDecimalNumber *first = [(SKProduct*)a price];
        NSDecimalNumber *second = [(SKProduct*)b price];
        return [first compare:second];
    }];
Run Code Online (Sandbox Code Playgroud)