草庐IT

converter-simplexml

全部标签

swift - 代码 9 : Cannot convert value of type '[String : Any]' to expected argument type '[NSAttributedStringKey : Any]?'

我有一个自定义的UIOutlineLabel类,它在标签内的文本周围绘制轮廓。自更新到Swift4后,我收到以下错误:无法将类型“[String:Any]”的值转换为预期的参数类型“[NSAttributedStringKey:Any]?”。我尝试将strokeTextAttributes更改为:as![NSAttributedStringKey:Any]但这会导致运行时错误。还有“UIOutlineLabelsetOutlineWidth已弃用并将在Swift4中删除”和“UIOutlineLabelsetOutlineColor已弃用并将在Swift4中删除”的Swift语言运行时

ios - '[CF字符串! ]' is not convertible to ' [字符串]'

在Swift1.2之前,我有以下数组:privateletphoneLabels=[kABPersonPhoneMobileLabel,kABPersonPhoneIPhoneLabel,kABWorkLabel,kABHomeLabel,kABPersonPhoneMainLabel,kABPersonPhoneHomeFAXLabel,kABPersonPhoneWorkFAXLabel,kABPersonPhonePagerLabel,kABOtherLabel]as[String]在我将Xcode更新到6.3之后,我不能这样了:privateletphoneLabels=[kA

ios - Swift 2.0 - "Cannot convert return expression of type ' NSURL' 返回类型 'String' "

我正在尝试将旧的swift应用程序转换为2.0,但似乎无法通过此函数中的这段代码:funcdocumentsPathForFileName(name:String)->String{letpaths=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true);letpath=paths[0];letfullPath=NSURL(fileURLWithPath:NSTemporaryDirectory()).URLByAppendingPathComponent(name)returnfullP

swift - 初始化程序中的三元运算符出现“Int 1' is not convertible to ' Bool”错误

以下代码在Xcode8.2.1中给我一个错误:UIColor(red:redSwitch.isOn?1:0,green:greenSwitch.isOn?1:0,blue:blueSwitch.isOn?1:0)错误是:'Int1'isnotconvertibleto'Bool'这是为什么呢?redSwitch.isOn在if语句条件下工作正常。苹果引用documentationsaysUISwitch.isOnreturnsBool.我如何让它工作? 最佳答案 这是一条垃圾错误消息,但问题只是您缺少UIColor的init(red

swift - "' [AnyObject] ' is not convertible to ' [狗]?从CoreData取数据时'"错误

我在从CoreData获取数据时遇到问题。如果我的术语不具体或不准确,我很抱歉,但我是CoreData的新手。我正在使用Xcode7beta和Swift2。设备操作系统设置为8.4。行:letresult=trymanagedContext.executeFetchRequest(dogFetch)as[Dog]?给我这个错误:“'[AnyObject]'isnotconvertibleto'[Dog]?'”。完整代码在这里:do{letdogEntity=NSEntityDescription.entityForName("Dog",inManagedObjectContext:ma

ios - 'NSString !' is not convertible to ' 字符串';您的意思是使用 'as!' 强制向下转换吗?

代码:varstrCategIds=""for(vari=0;i这个错误是什么意思?我花了很多时间在这上面。但没有成功。任何帮助将不胜感激。提前致谢 最佳答案 strCategIds+prCate.strCategoryIdas!String!编译为(strCategIds+prCate.strCategoryId)as!String!相反,我认为你应该:strCategIds+(prCate.strCategoryIdas!String) 关于ios-'NSString!'isnotc

c# - 将 base64 字符串转换为字节数组,如 C# 方法 Convert.FromBase64String

我在C#中有这个示例方法:publicstaticbyte[]FromBase64Url(stringdata){data=data.Replace('-','+').Replace('_','/');returnConvert.FromBase64String(data);}我想用Swift实现它。我试过这个:classfuncfromBase64(baseString:String)->[UInt8]{letdata=baseString.replace("-",withString:"+").replace("_",withString:"/")varbuff=[UInt8]()

swift 错误 : 'DYLD_BOOL' is not convertible to 'bool'

我正在开发一个简单的基于tableview的应用程序,如果用户触摸任何单元格,那么他将导航到DetailViewController,当用户单击DetailViewController时,他返回到我使用的tableView:overridefunctouchesBegan(touches:NSSet,withEventevent:UIEvent){self.dismissViewControllerAnimated(TRUE,completion:nil)}但是我以后不能在小的时候使用true并且那行给我这样的错误:'DYLD_BOOL'isnotconvertibleto'bool'

swift 错误 : (int) not convertible to int

这个问题在这里已经有了答案:PassinglistsfromonefunctiontoanotherinSwift(2个答案)关闭7年前。我正在阅读Apple的“Swift编程语言”指南并遇到以下问题。该书将求和函数定义为:funcsumOf(numbers:Int...)->Int{vars=0fornumberinnumbers{s+=number}returns}并包括一个“编写一个计算其参数平均值的函数”的实验,我试图重新使用sumOf来定义:funcaverageOf(numbers:Int...)->Float{varsum=sumOf(numbers)returnFloa

swift 3 : Int is not convertible to Bool in bitwise operation

不确定我在这里做错了什么,但这是破坏的微不足道的代码:if10&(1这给了我:'Int'isnotconvertibleto'Bool'怎么了? 最佳答案 不像在C中你可以写...if(x){}...这实际上是一个非零检查:if(x!=0){}您必须在Swift中测试bool条件。将!=0添加到您的语句中:if10&(1 关于swift3:IntisnotconvertibletoBoolinbitwiseoperation,我们在StackOverflow上找到一个类似的问题: