草庐IT

express-validator

全部标签

swift - 我在使用另一个文件的 swift 函数时遇到困难,我不断收到错误 "expression resolves to an unused function"

这是我尝试从不同文件调用的函数...funcsetLoginStatusT()->(){status=trueprintln("LoggedIn")ProgramStart()}我是这样调用它的……Main.setLoginStatusT“表达式解析为未使用的函数”到底是什么意思? 最佳答案 这个setLoginStatusT()->()意味着你正在返回一个函数。如果你不想退回任何东西,试试这个funcsetLoginStatusT(){//->(){status=trueprintln("LoggedIn")ProgramStar

ios - 为什么在命名 Swift 枚举大小写时出现 'is not a valid digit in integer literal' 错误?

我正在尝试创建一个带有运行距离的枚举,但是Swift不允许我以这种格式命名enum案例5K。我收到一条错误消息,提示'K'不是整数文字中的有效数字。这是我的代码: 最佳答案 标识符和类型属性/枚举案例不能以数字开头。您需要更改枚举的命名约定。enumRaceType:String{casefiveK="5K"casetenK="10K"casemarathon} 关于ios-为什么在命名Swift枚举大小写时出现'isnotavaliddigitinintegerliteral'错误?,

ios - 初始化 CBCentralManager : Type of expression is ambiguous without more context

尝试在Swift4.2项目中初始化CBCentralManager。获取评论中显示的错误:importCoreBluetoothclassSomeClass:NSObject,CBCentralManagerDelegate{//Typeofexpressionisambiguouswithoutmorecontextletmanager:CBCentralManager=CBCentralManager(delegate:self,queue:nil)//MARK:-Functions:CBCentralManagerDelegatefunccentralManagerDidUpda

ios - strip iOS 集成中的信用卡.validate CardReturningError(错误)

我正在尝试使用swift将Stripe集成到iOS应用程序中。我不断从该行收到这些错误:creditCard.validateCardReturningError(&error)错误1:'_'不可转换为'()throws->()'错误2:不可转换为“BooleanType”varerror:NSError?if(creditCard.validateCardReturningError(&error)){varstripeError:NSError!Stripe.createTokenWithCard(creditCard,completion:{(token,stripeError)

ios - 不清楚的 "Type of expression is ambiguous without more context"错误

几个月后我回到我的旧XCode项目,现在我有很多以前没有的错误,我假设这与更新的语法有关。为什么我会看到:Typeofexpressionisambiguouswithoutmorecontext对于这个block@IBActionfuncsubmitUrl(sender:UIButton){varapp=UIApplication.sharedApplication().delegateas!AppDelegate//ErroroccursinbelowdeclarationofstudentDictvarstudentDict=["latitude":self.latitude,"

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 - "Type of expression is ambiguous without more context"多维数组错误

我正在尝试创建一个数组,该数组最好以这种格式存储对象[[[String,CGPoint,Bool]]],但是到处都是错误,所以我决定将其设置为[[[AnyObject]]]。这是我声明数组的代码:varsavePlayerState:[[[AnyObject]]]=[]如您所见,它是一个多维数组,我需要在其中存储3个内容:当前时间、玩家位置和一个简单的Bool。以下是我尝试将数据保存到数组的方式:savePlayerState.append([timeLabel.text,player.position,isPlayerAlive])我的错误是:Typeofexpressionisam

ios - 代码 : module name "" is not a valid identifier while running XC unit test

尝试在使用SDWebImage设置的CocoaPods上运行XCTest,但我只能看到如下错误。有什么建议吗?:0:error:modulename""isnotavalididentifierCommand/Applications/Xcode8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftcfailedwithexitcode1但是一旦我编辑方案并取消选中构建中的测试,我就能够在模拟器上运行该应用程序但无法运行测试。 最佳答案

Swift NSDate 扩展错误 : Mutating isn't valid on methods in classes or class-bound protocols

我正在尝试扩展NSDate但出现两个错误:extensionNSDate{//'mutating'isn'tvalidonmethodsinclassesorclass-boundprotocolsmutatingfuncaddMonth(){letcalendar=NSCalendar.currentCalendar()letcomponent=NSDateComponents()component.month=1self=calendar.dateByAddingComponents(component,toDate:self,options:[])//Cannotassignto

ios - 如何解决 "Type of expression in ambiguous without more context"?

letattributedString=NSAttributedString(data:encodedData,options:attributedOptions,documentAttributes:nil,error:nil)!编译器错误:“表达式类型不明确,没有更多上下文”怎么解决的? 最佳答案 要求[String:AnyObject]attributedOptions参数要求的格式do{letencodedData=yourEncodedString.dataUsingEncoding(NSUTF8StringEncodin