草庐IT

values-ta

全部标签

json - 我如何修复 "Error Domain=NSCocoaErrorDomain Code=3840 "无值 ."UserInfo={NSDebugDescription=No value.}"

当我运行我的代码时,我得到这个错误,我不知道为什么。错误域=NSCocoaErrorDomain代码=3840“无值。”UserInfo={NSDebugDescription=无值。}我在网上找过,但没找到。这是我的代码:letmyUrl=NSURL(string:"http://foodhelper.club/registerUser.php");letrequest=NSMutableURLRequest(URL:myUrl!);request.HTTPMethod="POST";letpostString="userEmail=\(userEmail!)&userFirstNa

json - 我如何修复 "Error Domain=NSCocoaErrorDomain Code=3840 "无值 ."UserInfo={NSDebugDescription=No value.}"

当我运行我的代码时,我得到这个错误,我不知道为什么。错误域=NSCocoaErrorDomain代码=3840“无值。”UserInfo={NSDebugDescription=无值。}我在网上找过,但没找到。这是我的代码:letmyUrl=NSURL(string:"http://foodhelper.club/registerUser.php");letrequest=NSMutableURLRequest(URL:myUrl!);request.HTTPMethod="POST";letpostString="userEmail=\(userEmail!)&userFirstNa

swift 4 : Cannot subscript a value of type 'String' with an index of type 'CountablePartialRangeFrom<Int>'

所以我有这个快速代码:funcdidReceiveResponse(response:String){...letsubstr=response[11...]根据我的解释,substr应该是Substring引用响应字符串中索引11之后的所有字符。实际发生的是这个编译器错误:Cannotsubscriptavalueoftype'String'withanindexoftype'CountablePartialRangeFrom'这看起来应该是显而易见的,有人可以帮忙吗? 最佳答案 糟糕。看来我只需要这样做:letidx=respo

swift 4 : Cannot subscript a value of type 'String' with an index of type 'CountablePartialRangeFrom<Int>'

所以我有这个快速代码:funcdidReceiveResponse(response:String){...letsubstr=response[11...]根据我的解释,substr应该是Substring引用响应字符串中索引11之后的所有字符。实际发生的是这个编译器错误:Cannotsubscriptavalueoftype'String'withanindexoftype'CountablePartialRangeFrom'这看起来应该是显而易见的,有人可以帮忙吗? 最佳答案 糟糕。看来我只需要这样做:letidx=respo

swift - "Raw value for enum case is not unique"用于具有 Float 原始值的 Swift 枚举

根据TheSwiftProgrammingLanguage,我应该能够使用“字符串、字符或任何整数或float类型”的原始值创建一个Swift枚举。但是当我尝试时:enumBatteryVoltage:Float{casev3v7=3.7casev5v0=5.0casev7v4=7.4casev11v1=11.1casev12v0=12.0}...我得到一个编译错误:Rawvalueforenumcaseisnotunique在v7v4线上。它编译得很好,那个被注释掉了。但是啊,它看起来很独特。如果我将值设置为7.41、7.3或其他值,它可以正常编译。这是怎么回事?swift错误?

swift - "Raw value for enum case is not unique"用于具有 Float 原始值的 Swift 枚举

根据TheSwiftProgrammingLanguage,我应该能够使用“字符串、字符或任何整数或float类型”的原始值创建一个Swift枚举。但是当我尝试时:enumBatteryVoltage:Float{casev3v7=3.7casev5v0=5.0casev7v4=7.4casev11v1=11.1casev12v0=12.0}...我得到一个编译错误:Rawvalueforenumcaseisnotunique在v7v4线上。它编译得很好,那个被注释掉了。但是啊,它看起来很独特。如果我将值设置为7.41、7.3或其他值,它可以正常编译。这是怎么回事?swift错误?

swift 2 : expression pattern of type 'Bool' cannot match values of type 'Int'

我正在做这个问题集“FizzBu​​zz”,我的switch语句给我带来了一些问题,这是我的代码:funcfizzBuzz(n:Int)->String{switchn{casen%3==0:print("Fizz")casen%5==0:print("Buzz")casen%15==0:print("FizzBuzz")}return"\(n)"}如果你能给我指点/提示,而不是给我正确的代码,那就太棒了:D我更愿意自己解决它,但一些提示可以让我摆脱困境。 最佳答案 您可以使用caseletwhere并在单独检查之前检查两者是否匹配

swift 2 : expression pattern of type 'Bool' cannot match values of type 'Int'

我正在做这个问题集“FizzBu​​zz”,我的switch语句给我带来了一些问题,这是我的代码:funcfizzBuzz(n:Int)->String{switchn{casen%3==0:print("Fizz")casen%5==0:print("Buzz")casen%15==0:print("FizzBuzz")}return"\(n)"}如果你能给我指点/提示,而不是给我正确的代码,那就太棒了:D我更愿意自己解决它,但一些提示可以让我摆脱困境。 最佳答案 您可以使用caseletwhere并在单独检查之前检查两者是否匹配

ios - ( swift )PrepareForSegue : fatal error: unexpectedly found nil while unwrapping an Optional value

细节ViewController:@IBOutletvarselectedBundesland:UILabel!表格ViewController:overridefuncprepareForSegue(segue:UIStoryboardSegue!,sender:AnyObject!){if(segue.identifier=="BackToCalculator"){varvc:FirstViewController=segue.destinationViewControllerasFirstViewControllervc.selectedBundesland.text="Test

ios - ( swift )PrepareForSegue : fatal error: unexpectedly found nil while unwrapping an Optional value

细节ViewController:@IBOutletvarselectedBundesland:UILabel!表格ViewController:overridefuncprepareForSegue(segue:UIStoryboardSegue!,sender:AnyObject!){if(segue.identifier=="BackToCalculator"){varvc:FirstViewController=segue.destinationViewControllerasFirstViewControllervc.selectedBundesland.text="Test