我已完成将我的应用程序迁移到swift3,但此部分不断产生导致问题。
<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var Resultfieldname = "CheckboxChoices";
var firstVirtual = 1;
var lastVirtual = 3;
var ResultString = "";
var virtualFieldName = "";
for (i=firstVirtual ;i<=lastVirtual; i++)
{
virtualFieldName = "cbParamVirtual"+i;
if (document.getElementById(virtualFieldName).checked) ResultString = ResultString + "," + document.getElementById(virtualFieldName).value;
}
Resultfieldname = "EditRecord"+Resultfieldname;
if (ResultString.length>0) ResultString = ResultString.substr(1);
document.getElementById(Resultfieldname ).value = ResultString;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT>
重要控制台部件
- [_ SwiftValue unsignedIntegerValue]:无法识别的选择器发送到实例0x608000243d50 以NSException类型的未捕获异常终止 (lldb)
override func viewWillAppear(_ animated: Bool)
{
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
self.navigationItem.title = artworkTitle
let title = "<center><span style=\"font-size: 17px;font-weight:lighter;font-family:Avenir-Book;\">" + artworkCaption + "</span></center>"
artworkImageView.image = UIImage(named: artworkImagePath)
artworkCaptionView.attributedText = title.html2AttStr
}
控制台
extension String
{
var html2AttStr:NSAttributedString
{
let contents: NSMutableAttributedString?
do {
let attrTextStyle = NSMutableParagraphStyle()
attrTextStyle.alignment = NSTextAlignment.center
contents = try NSMutableAttributedString(data: data(using: String.Encoding.utf8)!, options:[NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8], documentAttributes: nil)
} catch _ {
contents = nil
}
libc ++ abi.dylib:以NSException类型的未捕获异常终止
答案 0 :(得分:7)
我记得reading on Apple's Swift blog如果你得到无法识别的选择器错误,这意味着Swift结构的自动包装会导致问题。最有可能的是它包裹String.Encoding
而不是将其转换为NSNumber
(NSMutableAttributedString
背后的Objective-C代码所期望的那样)。
尝试将NSCharacterEncodingDocumentAttribute: String.Encoding.utf8
替换为NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue