草庐IT

swagger-3.0

全部标签

swift - 如何使用调用回调的函数制作 swift 3.0 类?

我需要一些简单的方法来制作一个我可以使用Swift3.0传递和调用回调函数的类我不喜欢使用像通知中心或选择器之类的东西,前面有#。我很挑剔,也不喜欢打那么多字。示例:funcsetCallback(function:Callback){self.callback=function}funccallCallback(){self.callback()} 最佳答案 假设您有一些复杂的任务,并且您想要提供一个在任务完成时调用的回调:classComplexTaskManager{varcompletionHandler:(()->Void

swift - 通过使用 Swift 3.0 搜索结构值来获取包含结构的数组索引

我有一个保存数据的结构;structMyStruct{varage:Intvarname:String}我制作了一个数组并用数据填充它;varmyArray=[MyStruct]()myArray[0]=MyStruct(age:26,name:"John")myArray[1]=MyStruct(age:35,name:"Smith")如何找到myArray中包含名称“Smith”的元素的索引?编辑:这里有更多关于我需要使用来自Losiowaty的新代码找到位置的上下文;functableView(_tableView:UITableView,editActionsForRowAti

swift - 在 Swift 3.0 中检测 TextView 滚动以显示按钮

我在UIView中有一个TextView和一个隐藏按钮,我试图检测用户何时向下滚动到一长串文本的底部,并在他们到达底部时显示隐藏按钮。我看到一些关于如何在Obj-C中使用scrollViewDidScroll完成它的旧帖子,但不太确定如何使用swift来完成,或者如何使用TextView而不是ScrollView来完成。任何帮助都会很棒,因为我在这方面还没有走得太远。到目前为止,这是我将obj-cpost翻译成swift的尝试,但它对我没有用,事实上我什至不确定函数何时被调用:importUIKitclassMainVC:UIViewController,UIScrollViewDel

ios - 在 XCode 8.2/Swift 3.0 中更改状态栏样式(No "View controller-based status bar appearance")

我正在尝试修改状态栏的外观(将文本设为白色/将样式设置为“浅色”)。我设法通过将此添加到我的AppDelegate.swift文件来设置背景颜色:letstatWindow=UIApplication.shared.value(forKey:"statusBarWindow")as!UIViewletstatusBar=statWindow.subviews[0]asUIViewstatusBar.backgroundColor=UIColor(red:0/255.0,green:0/255.0,blue:0/255.0,alpha:1.0)但是,当我去更改状态栏文本的样式时,即使在“

ios - Firebase 3x 方法不适用于真实设备但适用于模拟器 Swift 3.0

我们正在使用GoogleFirebase3.x版本,我们遇到了来自Firebase的奇怪问题。我们使用的是Swift3.0,为了获取用户详细信息,我们使用以下代码片段:funcgetUserDetails(uidtext:String!,userBlock:@escaping(_details:AnyObject)->Void){//checkDBReferenceisnilornot.ifself.rootDBRef==nil{self.rootDBRef=FIRDatabase.database().reference()}//checkinputtextmustnotbeempt

ios - 从生成的 swagger 代码中使用 swift 客户端发布图像

我想使用生成的swift-client发布图像。经过大量研究,我认为最好的指定方式是:/user/profilepicture:put:description:|uploadprofilepictureofuserconsumes:-multipart/form-dataparameters:-name:profilePhotoin:formDatatype:file生成的swift客户端函数签名为:publicclassfuncusersProfilepicturePut(profilePhotoprofilePhoto:NSURL?=nil,completion:((error:E

ios - swift 3.0 : Unable to infer closure type in the current context , PromiseKit

我在swift3.0中有以下代码,我在其中使用PromiseKit。funccalculateTravelTime(from:CLLocation,to:CLLocation)->Promise{Promise{completion,reject->Voidinletrequest=MKDirections.Request()request.transportType=.walkingletfromPlacemark=MKPlacemark(coordinate:from.coordinate)lettoPlacemark=MKPlacemark(coordinate:to.coord

ios - MailComposer didFinishWith 结果在 Swift 3.0 中不起作用

我将我的应用程序转换为swift3.0,但MailComposeController出现问题。当我调用函数时:`funcmailComposeController(_controller:MFMailComposeViewController,didFinishWithresult:MFMailComposeResult,error:Error?){controller.dismiss(animated:true,completion:nil)}`首先我有一个信息错误:对我来说有什么奇怪的,因为我从MFMailComposeViewControllerDelegate复制并粘贴了这个方

ios - 如何将 pod 更新到 Swift 3.0

目前正在迁移到Swift3.0。这是我第一次做这样的事情,我不完全确定如何处理我正在使用的各种pod。例如我正在使用podSwiftDate:https://github.com/malcommac/SwiftDate.Swift3.0分支不在master上,所以我假设运行podupdate不会拉取Swift3.0版本。我放置pod是否正确:'SwiftDate',:git=>'https://github.com/malcommac/SwiftDate.git',:branch=>'feature/swift-3.0'进入我的podfile然后运行更新?检查github页面似乎这是正

swift - 在 Swift 3.0 中遍历枚举

我有一个简单的枚举,我想对其进行迭代。为此,我采用了Sequence和IteratorProtocol,如下面的代码所示。顺便说一句,这可以复制/粘贴到Xcode8中的Playground。importUIKitenumSections:Int{caseSection0=0caseSection1caseSection2}extensionSections:Sequence{funcmakeIterator()->SectionsGenerator{returnSectionsGenerator()}structSectionsGenerator:IteratorProtocol{va