I'm running Xcode 6.3 beta 1 with iOS 8.3 beta 1 in the iOS Simulator. I have a UITextField
@IBOutlet
of which I'm trying to get the uppercaseString
property of its text
property, like this:
@IBOutlet weak var field: UITextField!
@IBAction func calledAfterUserAction(){
let capitalized = field.text.uppercaseString
}
The above workflow will cause a crash. After turning on Zombie Objects, I can see the following error:
*** -[CFString release]: message sent to deallocated instance 0x7b689cd0
How can I fix this?
I just ran into the same problem - very glad you posted this so that I knew I wasn't crazy!
I've discovered that the simple "uppercaseString" method fails with a deallocated object error, while the extended version that takes a Locale works. I'm guessing there is an internal Apple bug over handling default locales... Change your code to:
let capitalized = field.text.uppercaseStringWithLocale(NSLocale.currentLocale())