//
//  OrderTableViewCell.m
//  ALand
//
//  Created by Z on 16/3/30.
//  Copyright © 2016年 Z. All rights reserved.
//

#import "OrderTableViewCell.h"
#import "OrderCellView.h"

@interface OrderTableViewCell ()
@property (nonatomic, strong) NSMutableArray *arrCellView;
@property (weak, nonatomic) IBOutlet UILabel *labelState;

@end
@implementation OrderTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.arrCellView = [NSMutableArray array];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)cellWithViewNumber:(NSInteger)number {
    //[self.contentView removeAllSubViews];
    for (OrderCellView *cellView  in self.arrCellView) {
        [cellView removeFromSuperview];
    }
    
    
    
//    //1.获取一个全局串行队列
//    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//    //2.把任务添加到队列中执行
//    dispatch_async(queue, ^{
//        
//        //打印当前线程
//        CLog(@"%@",[NSThread currentThread]);
//        
    
        for (NSInteger i = 0; i < number; i++) {
            
            
            
            OrderCellView *cellView = [OrderCellView viewWithNibName:@"OrderCellView"];
            cellView.frame = CGRectMake(0, 74 + 120 * i, self.width, 120);
            
//            //回到主线程，展示图片
//            dispatch_async(dispatch_get_main_queue(), ^{
//                //打印当前线程
//                CLog(@"%@",[NSThread currentThread]);
                [self.arrCellView addObject:cellView];
                [self.contentView addSubview:cellView];
//            });
//            
        }
    
        
//    });
    
    
}

- (void)setState:(NSString *)orderState {
    self.labelState.text = orderState;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
