草庐IT

converter-simplexml

全部标签

ios - Alamofire 4.0.0 : [String:String] is not convertible to [String : Any] & Request is ambiguous without more context

我正在将Alamofire更新到4.0.0Beta1并将XCode8更新到Beta6。首先,我得到了[String:String]isnotconvertibleto[String:Any]错误代码letparameter=["scope":"\(scope)","client":"\(clientId)"]Alamofire.request(link,withMethod:.POST,parameters:parameter,encoding:.json).responseJSON在我更改后将[String:Any]添加到参数中,错误消失但产生了新错误:Expressiontype'

ios - swift 4 中的“UIImage ?' is not convertible to ' UIImage”问题

我正在尝试实现一个图像选择器。在委托(delegate)方法中,我收到以下错误。或这是我写的代码funcimagePickerController(_picker:UIImagePickerController,didFinishPickingMediaWithInfoinfo:[UIImagePickerController.InfoKey:Any]){varimage=info[.editedImage]as?UIImageifimage==nil{image=info[.originalImage]as?UIImage}simpleImagePicker!.dismiss(ani

ios - 准备 segue : Cannot convert value of type 'UIViewController' to specified type 'SecondViewController'

我知道我肯定在这里遗漏了一些明显的东西,但我似乎无法通过它的实际类型来引用目标ViewController。我按照以下步骤从头开始创建了一个新项目来对此进行测试:创建一个新的单View应用程序项目添加一个新的ViewController创建一个新类,子类化UIViewController,并将其命名为SecondViewController将这个新类设置为第二个ViewController的自定义类(现在它的标题是第二个ViewController)向第一个ViewController添加一个按钮,然后按住Ctrl键单击它到第二个ViewController,然后从ActionSegu

ios - swift 3.1 : Cannot convert value of type '(_) -> ()' error/Problems with closures

我升级到Swift3.1,我收到了一些新错误,这些错误似乎是3.1语法问题,因为在迁移之前它们不是问题。它们大多与闭包有关,如本例所示:letalert=UIAlertController(title:"Success",message:"Thanksforparticipatinginourraffle!",preferredStyle:UIAlertControllerStyle.alert)alert.addAction(UIAlertAction(title:"OK",style:.default,handler:{performSegue(withIdentifier:"to

swift - 错误 : Cannot convert value of type 'URL' to expected argument type 'String'

我在将URL转换为字符串时遇到问题。getScreenShotDirectory()路径是file:///Users/Pat/Desktop/。我的目标是将其转换为字符串,因此路径可以类似于/Users/Pat/Desktop/leturlString=getScreenShotDirectory()letpathURL=URL(string:getScreenShotDirectory())!//error如果需要,我很乐意提供更多代码。 最佳答案 看来您的getScreenShotDirectory()方法已经是一个URL。因此

struct - 错误 : 'Int' is not convertible to '@lvalue Float'

给定以下函数:funcgreatestCommonDenominator(first:Int,second:Int)->Int{returnsecond==0?first:greatestCommonDenominator(second,first%second)}还有一个包含以下内容的结构:structFraction{varnumerator:Intvardenominator:Intfuncreduce(){letgcd=greatestCommonDenominator(numerator,denominator)self.numerator/=gcdself.denomina

xcode - 快速 Xcode 单元测试 : Cannot convert value of type "Person" to expected argument type "Person"

我正在尝试编写一个单元测试类来测试我的自定义类。当我尝试使用自定义对象作为输入变量调用自定义类中的方法时,我得到:'无法将类型“Person”的值转换为预期的参数类型“Person”。“Person”是从NSManagedObject继承的类,输入对象是从中创建的。我对采用其他值类型的其他方法没有问题。该方法工作正常。测试类是唯一提示这个的。这是错误还是限制?有什么建议可以让我更深入地研究这个问题吗? 最佳答案 我之前遇到过这个问题。事实证明,被测系统(在我的例子中是调用对象的服务;对于您的示例,可能是PersonService)没

swift - iOS Swift 错误 : 'T' is not convertible to 'MirrorDisposition'

我正在尝试为Array类型创建一个扩展方法,以允许从数组中删除一个项目extensionArray{funcremove(item:AnyObject){forvari=self.count-1;i>=0;i--{ifself[i]==item{self.removeAtIndex(i)}}}}关于测试条件ifself[i]==item,我收到以下错误:'T'isnotconvertibleto'MirrorDisposition'我尝试过很多不同的东西,包括:使用泛型:remove(item:T)使用===运算符,它只给出错误'T'doesnotconformtoprotocol'A

swift - '[任务] ?' is not convertible to ' 可选<[任何]>'

我做了扩展extensionOptionalwhereWrapped==[Any]{varisNilOrEmpty:Bool{get{ifletarray=self{returnarray.count==0}else{returnfalse}}}}然后我尝试这样使用它iffetchedResults.fetchedObjects.isNilOrEmpty{...}我遇到了错误'[Task]?'isnotconvertibleto'Optional'但是,根据规范Anycanrepresentaninstanceofanytypeatall,includingfunctiontypes.

swift - 自更新到 Swift 1.2 以来,字典现在给出错误 'not convertible to BooleanLiteralConvertible'

我刚刚开始了解Swift-然后Swift1.2来了(打破了我的工作代码)!我有一个基于NSHipster-CGImageSourceCreateThumbnailAtIndex中代码示例的函数.我以前的工作代码是:importImageIOfuncprocessImage(jpgImagePath:String,thumbSize:CGSize){ifletpath=NSBundle.mainBundle().pathForResource(jpgImagePath,ofType:""){ifletimageURL=NSURL(fileURLWithPath:path){ifletim