我正在将大型代码库迁移到Swift 3.0。我生成错误if(!isset($_SESSION['cart_items'])){
$_SESSION['cart_items'] = array();
}
// check if the item is in the array, if it is, do not add
if(array_key_exists($id, $_SESSION['cart_items'])){
// redirect to product list and tell the user it was added to cart
header('Location: products.php?action=exists&id' . $id . '&name=' . $name);
}
// else, add the item to the array
else{
$_SESSION['cart_items'][$name]['price']=$price;
if (!empty($quantity)){
echo "adding qty";
$_SESSION['cart_items'][$name]['quantity']=$quantity;
}
// redirect to product list and tell the user it was added to cart
// header('Location: products.php?action=added&id' . $id . '&name=' . $name);
}
我甚至尝试将newValue设置为"Cannot convert value of type 'Array<MultivalueEntry<Date>>?' to type 'AnyObject' in coercion.
以下,但仍然会产生错误:
最后尝试将newValue设置为'Array<MultivalueEntry<Date>>?'
但没有成功:
我做错了什么?
更新MultiValueEntry:
'Array<MultivalueEntry<NSObject>>?'
答案 0 :(得分:1)
问题是泛型数组无法转换为NSArray或CFArray,因为Objective-C对泛型一无所知。好吧,MultivalueEntry<Date>
是通用的。