I am reading a static Stream of Ints into an Array of Ints:
func create_int_array_from_nsmutable(nsdata:NSMutableData) -> [Int] {
let pointer = UnsafePointer<Int>(nsdata.bytes)
let count = nsdata.length / sizeof(Int);
// Get buffer pointer and make an array out of it
let buffer = UnsafeBufferPointer<Int>(start:pointer, count:count)
let array = [Int](buffer)
return array;
}
Now I realize, that in the iPhone 5 an Int has a size of 4 and on iPhone 6 or the iPad has a size of 8, which leads to totally different results.
Has someone a hint how to read this stream in both cases and get the same result?
Should I use the Int64
Type? Does Int64
exists exact for that reason, e.g. to solve compatibility problems?