Reputation: 459
I have experienced a bug in an IOS app written in swift that I have been able to reproduce in a simple playground : the code is the following one :
import UIKit
import Foundation
var textField = UITextField()
textField.text = "Foo"
let content = textField.text
println(content.uppercaseString)
The error message is the following one :
Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. * thread #1: tid = 0x657a84, 0x000000010be3e4c6, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) * frame #0: 0x000000010be3e4c6
On the other hand the following code works great :
let testString = "Bar"
println(testString.uppercaseString)
Is there something I have missed in memory management with Swift or in bridging String and NSString ?
Thanks in advance.
Upvotes: 1
Views: 2775
Reputation: 10283
I've reproduced the crash here and it looks suspiciously like you've found a bug in uppercaseString
to me. File a bug with the code you've provided.
While Apple are fixing this, I got this workaround to work:
var upper = content.uppercaseStringWithLocale(NSLocale.currentLocale());
Upvotes: 2