0
Swift 2.1'de, NSCopying protokolüne uygun bir sınıf nasıl oluşturmalıyım? swift - NSCopying sınıfı
bu çalıştı:class TargetValue: NSObject, NSCopying {
var value: Int?
func copyWithZone(zone: NSZone) -> AnyObject {
let copy = TargetValue()
copy.value = value
return copy
}
}
var target = TargetValue()
target.value = 12
var target1 = target.copy()
print(target1.value) // ambiguous user of 'value'
Ama ambiguous user of value
hatasını çarptı. Bu sorunu çözmek için ne yapmalıyım? Eğer beklenen türüne kopya döküm zorunda
Selamlar
aptalmışım bu kaçırmak! Çok teşekkürler, Troy – quanguyen