当我更改 iphone 的语言时会导致崩溃?

when i changed language of iphone its causing crash?

   let initialStr = "To see information for today, please"

        let tempFontSize = UIUtils.getFontForApproprieteField(.subHeadline).font.pointSize

        let tealDict = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: tempFontSize), NSAttributedStringKey.foregroundColor: UIColor.LTColor()]
        let linkAttributes = [NSAttributedStringKey.foregroundColor: UIColor.LTColor(), NSAttributedStringKey.underlineStyle: NSNumber(value: false as Bool)]
        errorLbl?.linkAttributes = linkAttributes
        errorLbl?.delegate = self

        let attributedString = NSMutableAttributedString(string: AppMessage.emptyWidget, attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: tempFontSize)])
        attributedString.addAttributes(tealDict, range: NSMakeRange(initialStr.length+1,3))
        errorLbl?.attributedText = attributedString

        let rangeT : NSRange = (AppMessage.emptyWidget as NSString).range(of: " add")
        errorLbl?.addLink(to: URL(string: "https://www.google.co.in/")!, with: rangeT)

我想将 Add 设为 please 之后的超链接。它适用于所有设备,除非我们更改语言时此行会导致崩溃。

当我更改 iphone 这一行的语言时导致崩溃?

languageChange :- 英语 -> 印地语

崩溃:

Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds'

AppMessage.emptyWidget 是一个本地化字符串,但键在 localised.string 中没有相应的值,这就是为什么会出现范围问题。 添加了 key 的值,app 运行正常。