My code calls String.appendingFormat
to append a formatted string to a value that is used as output in an iPhone app. When the call includes the format string and two value arguments (e.g. ("The numbers are %d and %d", number1, number2))
, it works fine on the simulator, but on my iPad, the second value is always treated as zero.
Note that, in each case, the value comes from a Int64
array.
Why would it work differently on an actual device than in the simulator?
Here's a better-formatted version of my reply (one of these days, I'm going to remember that newlines get swallowed in replies):
var results = [Int64]()
var A: Int64 = 123
results.append(A)
On the simulator, results[0] = 123
On the iPad, results[0] = what looks like a pointer; it's an 11-digit number that changes each time the code is executed
var outputString: String = ""
outputString = outputString.appendingFormat("%d %d", A, results[0])
On the simulator, outputString = "123 123"
On the iPad, outputString = "123 0"