我为不同的Cell Identifiers创建了一个结构:
view.tableForItems.register(UINib.init(nibName: cellIdentifier, bundle: nil), forCellReuseIdentifier:cellIdentifier)
我按照开关案例将单元格注册到表中,如:
reuseIdentifier
但是当我注册单元格时,错误地认为 class CustomTableCell: UITableViewCell
{
override func awakeFromNib()
{
super.awakeFromNib()
// Initialization code
switch self.reuseIdentifier ?? "cellForCountry" //It only work with country cell
{
case CustomCellIdentifiers.cellForCountry:
print("cellForCountry") break;
case CustomCellIdentifiers.cellForCity:
print("cellForCity") break;
case CustomCellIdentifiers.cellForStoreType:
print("cellForStoreType")
break;
default: break
}
}
}
是nil:
$filters = array(
'post_status' => 'published',
'post_type' => 'shop_order',
'posts_per_page' => 200,
'paged' => 1,
'orderby' => 'modified',
'order' => 'ASC',
'author' => $seller_id,
'post_parent' => $order_id
);
$loop = new WP_Query($filters);
while ($loop->have_posts()) {
$loop->the_post();
$order = new WC_Order($loop->post->ID);
foreach ($order->get_items() as $key => $item)
{
$red = $item['product_id'];
$_sku = get_post_meta( $red, '_sku', true );
}
}