2017-12-19 27 views
0
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) 

은 내가 가 하이퍼 링크로 하십시오 이후 추가 만들고 싶어. 이 라인을 변경했을 때를 제외하고는 모든 장치에서 작동하므로 충돌이 발생합니다.내가 아이폰의 언어를 변경했을 때 충돌이 발생 했습니까?

내가 아이폰의 언어를 변경했을 때이 줄이 충돌을 일으켰습니까?

languageChange : - 영어 -> 힌디어

충돌 : 응용 프로그램을 종료

인해 캐치되지 않는 예외 'NSRangeException'이성 'NSMutableRLEArray objectAtIndex : effectiveRange ::의 아웃 바운드'

+0

즉, 전달하는 범위가 올바르지 않습니다. 디버깅해야합니다. –

+0

이 디버깅되었습니다. nslocalised 문자열 키에 부식 값이 없습니다. – Amey

답변

0

AppMessage.emptyWidget은 지역화 된 문자열이지만 localised.string에 해당 값이없는 키 때문에 범위 문제가 있었던 이유입니다. 키와 앱의 가치를 추가했습니다.