I have just updated to the newest Xcode 6.3 beta and I am receiving an error that I can't figure out the solution to.
When I run my app, I am getting the error: Command failed due to signal: Segmentation Fault 11
. I had a look through the full error message and I have taken the parts out that I think are relevant:
(unresolved_dot_expr type='@lvalue String!' location=/Filename/FifthViewController.swift:423:19 range=[/Filename/FifthViewController.swift:423:9 - line:423:19] field 'text'
(declref_expr type='UITextField' location=/Filename/FifthViewController.swift:423:9 range=[/Filename/FifthViewController.swift:423:9 - line:423:9] decl=AffordIt.(file).FifthViewController.func decl.textField@/Filename/FifthViewController.swift:418:34 specialized=yes))
And
While emitting SIL for 'textFieldDidChangeValue' at /Filename/FifthViewController.swift:418:5
Anyone have any ideas? Obviously I've replaced the full path with 'Filename'. This is the code related to the error:
textField.addTarget(self, action: "textFieldDidChangeValue:", forControlEvents: UIControlEvents.EditingChanged)
func textFieldDidChangeValue(textField: UITextField) {
//Automatic formatting for transaction value text field. Target is added above.
var text = textField.text.stringByReplacingOccurrencesOfString(currencyFormatter.currencySymbol!, withString: "").stringByReplacingOccurrencesOfString(currencyFormatter.groupingSeparator, withString: "").stringByReplacingOccurrencesOfString(currencyFormatter.decimalSeparator!, withString: "").stringByReplacingOccurrencesOfString("?", withString: "") // There is a special character here. This line is critical for european/other currencies.
println(textField.text)
textField.text = currencyFormatter.stringFromNumber((text as NSString).doubleValue / 100.0)
currencyDouble = (text as NSString).doubleValue / 100.0
valueEnter.alpha = 1
}
Here is the initialisation of currencyFormatter:
let currencyFormatter = NSNumberFormatter()
currencyFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
if let currencyCode = NSLocale.currentLocale().objectForKey(NSLocaleCurrencyCode) as? String {
currencyFormatter.currencyCode = currencyCode
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…