草庐IT

dispatch-after

全部标签

swift - DispatchQueue.main.asyncAfter(deadline : . now() + 5.0) 如何在 Swift 3 中工作?

在Swift3中,GCD的语法发生了很大变化。对dispatch_after()的调用现在看起来像这样:DispatchQueue.main.asyncAfter(deadline:.now()+5.0){//dosomething}该代码会在block被调用5秒后调用它。这是如何运作的?文档说deadline参数是dispatch_time_t,它是UInt64的类型别名。我假设它是以纳秒为单位的马赫时间。但是,.now()+delay语法将小数秒添加到值中。DispatchTime.now()不返回UInt64吗?如果是这样,向其添加小数秒应该不起作用。如果有的话,我希望添加到.n

swift - 完成处理程序 dispatch_async 出错?

这个问题在这里已经有了答案:HowdoIdispatch_sync,dispatch_async,dispatch_after,etcinSwift3,Swift4,andbeyond?(6个答案)关闭5年前。我在下面的函数中有完成处理程序staticfuncfetchFeatureApp(completionHandler:@escaping([AppCategory1])->()){leturlString="http://ebmacs.net/ubereats/Api/all_product?id=1"leturl=URL(string:urlString)!URLSession

ios - 导航 Controller :willShowViewController:animated: is not called after popToRootViewControllerAnimated in presented view controller

我有UINavigationController和几个推送的ViewController。UPD:最后按下的Controller模态呈现另一个Controller。另外,我在navigationController:willShowViewController:animated:中有一些逻辑UINavigationControllerDelegate。UPD:导航Controller是它自己的委托(delegate)。委托(delegate)在viewDidLoad方法中设置。问题当我尝试从呈现的ViewController中以编程方式关闭所有Controller时出现://Close

arrays - 数组在 dispatch_barrier_sync 上损坏

我有2个将数据附加到数组的函数和一个处理它的函数。我使用dispatch_barrier_sync来防止其他函数在我处理数据时更改数据。内部追加函数:autoreleasepool{dispatch_barrier_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)){[weakself]()->Voidinself?.bufferVector_.append(data)}}内部流程函数:autoreleasepool{dispatch_barrier_sync(dispatch_get_global_qu

ios - AWS S3 iOS SDK : How to resume upload after connection is interrupted?

这是我完成上传任务的代码:letimage=UIImage(named:"12.jpeg")letfileManager=FileManager.defaultletimageData=UIImageJPEGRepresentation(image!,0.99)letpath=(NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0]asNSString).appendingPathComponent("\(imageData!).jpeg")fileManager.createFil

swift - 将 Swift 类标记为 final 是否也会使所有包含的 var、let 和函数自动获得 Static Dispatch 的好处?

我正试图从我的应用程序中榨取最后一点性能。我尝试尽可能在类上使用Structs(没有状态共享,默认情况下直接分派(dispatch)等等)。但是我的ViewController和UIView对象显然仍然是类。出于性能原因,我想对我的每一个方法和数据成员强制执行直接调度。我是否还需要在我的类(class)中标记每个var、let和funcfinal,或者是是否足以将托管类标记为最终类,以便其下的所有内容都可以利用直接方法分派(dispatch)?换句话说:在每个方法和变量之前都粘贴final非常乏味。所以我希望将它放在类(class)本身上具有强制直接dispatch所有类(class)

org.apache.kafka.common.errors.TimeoutException:Topic xxx not present in metadata after 60000ms.

1.发现问题:服务中向kafka的一个topic发送消息,报了这个错误org.apache.kafka.common.errors.TimeoutException:Topicxxxnotpresentinmetadataafter60000ms.2.排查思路:手动连接kafka,打开两个窗口一个向xxx这个topic发送消息,另一个看能否正常消费消息。窗口1:执行发送消息命令bin/kafka-console-producer.sh--broker-list192.168.65.60:9092,192.168.65.60:9093,192.168.65.60:9094--topicxxx窗口

ios - swift 2 : How to Load UITabBarController after Showing LoginViewController

我是Swift和Storyboard的新手。最初我必须显示登录页面并从登录页面显示到UITabBarController。一旦用户记住了登录详细信息,我必须检查AppDelegate中的登录详细信息,如果用户已经登录,则直接显示UITabBarController。我已经提到了一些SOF问题,但没有得到结果。IdesignedtheLoginViewControllerembeddedwithUINavigationController.AndIhaveoneUITabBarControllerwith2viewcontrollers.IsettheLoginViewControlle

multithreading - Swift dispatch_after throwing is not a prefix unary operator 错误

我有以下代码:importSpriteKitimportFoundationclassGameScene:SKScene{varoccupiedCoordinates:NSMutableArray=NSMutableArray()funcaddShape(){//...shape.position=CGPoint(x:actualX,y:actualY)self.occupiedCoordinates.addObject(NSValue(CGPoint:shape.position))lethalfDuration=random(min:CGFloat(0.5),max:CGFloat

ios - UITest 无法终止 com.test.abc :3708 after 60. 0s;状态仍然是`Running Foreground

我的应用程序有UITests,所有测试都运行良好,但有时在执行几个测试后,其他测试开始失败,原因是Failedtoterminatecom.test.abc:3708after60.0s;状态仍然是RunningForeground(4)CreateUserUITest 最佳答案 看起来是Xcode的bug还没有解决。http://www.openradar.appspot.com/25548393我尝试使用@try{}@catch{}但如果terminate()失败,测试仍然会中断。所以我只看到一种修复=删除应用程序的方法,如果它