我想修改CNPostalAddress
从 a 的postalAddress
属性获得的 a的值CLPlacemark
。
由于CNPostalAddress
具有不可变的属性,我想将其转换为CNMutablePostalAddress
. 但是,似乎没有一种干净的方法可以做到这一点。我目前的方法是这样的:
extension CNPostalAddress {
var mutableAddress: CNMutablePostalAddress {
let address = CNMutablePostalAddress()
address.city = city
address.country = country
address.postalCode = postalCode
address.state = state
address.street = street
[...]
return address
}
}
有没有更好的方法来进行这种转换?