在我的应用中,我正在将一个对象从我的应用传递到我的捆绑包中。问题在于Swift认为它们是另一种类型。因此,当我进行检查时,它将失败,并说MyApp.Restaurant
与MyBundle.Restaurant
是不同的。
func exportRestaurant(_ restaurant: Restaurant) {
if let restaurant: Restaurant = restaurant as? Restaurant {
// This will never be executed.
}
let restaurant: Restaurant = restaurant as! Restaurant
// This will crash the app. Could not cast value of type 'MyApp.Restaurant' (0x100ba6460) to 'MyAppSupportingBundle.Restaurant' (0x104eaaec0).
}
因此,我无法将其转换为类型。有什么办法可以克服这个问题?