I've read several posts here and here and I understand the "why". None of the suggestions in these posts functioned for me, but doing the conversion a step at a time did. This feels like a hack to me and like I'm missing something.
I've included the final bit of code here.
My Scenario:
- Step 1: Store CoreData Object as Primitive Int32 (not shown in code)
- Step 2: Fetch NSNumber Object (Showing just the needed code)
- Step 3: NSNumber to Int
Step 4: Cast Int to Int32
var finalQTY:Int32 //Step 2 if let retQTY = managedObject.valueForKey("totQty") as? NSNumber { //Step 3 let preQTY = retQTY as Int //Step 4 finalQTY = Int32(preQTY) }
Is there a better way? I feel like I am missing something? (Using Int is not an option because of the size of the numbers involved. I used QTY here but that was just as an example). Your feedback and responses are greatly appreciated as I continue to learn Swift.