Dovrebbe essere facile ma posso solo trovare la conversione inversa. Come posso convertire Int32 in Int in Swift? A meno che il problema non sia diverso?Come posso convertire Int32 in Int in Swift?
Ho un valore memorizzato in Dati principali e voglio restituirlo come Int.
Ecco il codice che sto usando, che non funziona:
func myNumber() -> Int {
var myUnit:NSManagedObject
myUnit=self.getObject(“EntityName”) // This is working.
return Int(myUnit.valueForKey(“theNUMBER”)?.intValue!)
}
'lasciare i32 = UInt32 (911)' 'e poi lasciare che i = Int (i32)' spero che questo aiuta –
intValue torna Int32 è possibile utilizzare interoValore per restituire Int –
return myUnit.valueForKey ("theNUMBER")?. interoValue ?? 0 –