I'm developing an app that will share data cross platform specifically between iOS and macOS. I'm using NSCoding to serialize my model to a file. A specific property in my data model is of type Int. Below is a section of code that runs on both iOS and macOS:
class MyDataModel: NSObject, NSCoding {
struct Keys {
static let myNumber = "myNumber"
}
var myNumber: Int = 0
required init(coder aCoder: NSCoder) {
super.init()
myNumber = aDecoder.decodeInteger(PropertyKey.nameKey)
}
fun encode(with aCoder: NSCoder) {
aCoder.encodeInteger(myNumber, forKey: PropertyKey.ratingKey)
}
}
The question is, if I save this integer on iOS into a file on iCloud, and then open the file and decode in on macOS will the data remain the same? I have heard rumors that Int are interpreted differently on these two platforms. I was even recommended to store my integers as strings and then cast them into an integer. Could someone confirm whether this is true or not?