草庐IT

dispatch_after

全部标签

ios - 火力地堡 : How to removeObserver(withHandle:) after observeSingleEvent()?

我将Firebase数据库与swift结合使用。当我使用databaseReference.observe(...)进行观察时,我可以轻松地从DatabaseReference中删除观察者:databaseHandle=databaseReference.observe(.value,with:{(snapshot)in...},withCancel:{(error)in...})...databaseReference.removeObserver(withHandle:databaseHandle)我的问题是当我使用databaseReference.observeSingleEv

ios - dispatch_async 是否可以中断调用任务

假设我将任务异步分派(dispatch)到队列:{//weareonmainqueuedispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{print("taskB")});print("taskA")//somelongrunningworkprint("taskA")//somelongrunningworkprint("taskA")...}在任何情况下,分派(dispatch)的任务都可以中断从中分派(dispatch)它的任务吗?换句话说,是否会在打印所有“任务A”之前打印“

ios - 应用程序 :openURL:options: not called after opening universal link

我已经使用BranchSDK设置了通用链接。链接正确打开应用程序,并且application:continueUserActivity:restorationHandler:被调用,但不是`application:openURL:options:'funcapplication(_app:UIApplication,openurl:URL,options:[UIApplicationOpenURLOptionsKey:Any]=[:])->Bool{Branch.getInstance().application(app,open:url,options:options)returnt

Swift/CloudKit : After record changed, 上传触发器 "Service Record Changed"

我正在尝试将CKReference添加到云工具包中的记录,但尝试不断触发“服务记录已更改”。从我的println显示的控制台消息(下面的控制台消息和代码),我正在上传带有0个引用的记录,然后当我附加引用时,我看到尝试上传带有1个引用的记录。然后我收到错误。据我所知,不应触发“服务记录已更改”,因为引用列表中的值已更改(记录有一个完整的额外字段)。即使我在开发模式,我手动为ReferenceList创建了key-value字段,因为当referencelist为空时,第一次上传的记录不包括该字段(上传空数组会导致另一个错误)。我将在控制台消息之后按照相关性顺序包含代码(您将能够看到大部分

ios - 使用 performBackgroundTask 将多个核心数据插入分派(dispatch)到 NSPersistentContainer 时合并冲突

我正在试验新的核心数据APINSPersistentContainer,我的印象是内部排队机制会阻止写入事务并发评估,详见堆栈溢出答案NSPersistentContainerconcurrencyforsavingtocoredataThewaythatalotofproshavebeendealingwiththeproblemforalongtime(evenbeforeNSPersistentContainerdidit)wastohaveanoperationqueuetoqueuethewritessothereisonlyonewritegoingonatatime,an

ios - 在 Swift 中,如何从 dispatch_time_t 获取 NSDate?

“Walltime”是GrandCentralDispatch使用的一种鲜为人知的时间格式。苹果在这里谈论它:https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/虽然有些事情确实很方便,但它是一个粘性wicket。很难让它与其他时间格式兼容,这就是我的问题所在。我可以通过将NSDate转换为timespec来制作walltime,然后使用dispatch_walltime:letnow=NSDate().timeIntervalSince1970l

swift - swift 3.0 中的 dispatch_group_async 函数

我的问题是如何在Swift3中正确翻译此函数,因为我注意到有很多关于dispatch_async的文档,但没有任何关于dispatch_group_async的文档>dispatch_group_async(group,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0)){[unownedself]in 最佳答案 试试这个:letgroup=DispatchGroup()DispatchQueue.global(qos:.userInitiated).async(group:g

ios - swift 中的 dispatch_block_t 相当于什么?

我有一些我想理解的objective-c代码,以便在swift中执行相同的操作:dispatch_block_tadjustTooltipVisibility=^{self.tooltipView.alpha=_tooltipVisible?1.0:0.0;self.tooltipTipView.alpha=_tooltipVisible?1.0:0.0;};到目前为止,关于dispatch_block_t我能找到的所有信息是它在swift的dispatch_after中用作闭包。所以我能理解,但我不明白它在objective-c中的用法,以及如何将这段代码转换为swift代码

ios - swift/iOS : IBOutlet nil after loading view controller

我正在构建一个应用程序(在XCode8.2.1中),其中一些对象显示在2D板上,当用户点击这些对象之一时,应该将有关它的一些信息显示为样式化的模态信息框。我的设计是将信息写在一个单独的ViewController中,我会在需要时显示它。我为第二个ViewController设计了一个基本stub,并在界面生成器中为其添加了一个标签。然后我将这个标签链接到我的自定义VC类:classInfoViewController:UIViewController{@IBOutletweakvarinfo:UILabel!overridefuncviewDidLoad(){super.viewDid

ios - 具有父类(super class)和子类的 Swift 协议(protocol)扩展方法分派(dispatch)

我发现了一个有趣的行为,它看起来像是一个错误......基于以下文章描述的行为:https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatch-6a6bf270ba94http://nomothetis.svbtle.com/the-ghost-of-swift-bugs-future当我添加SomeSuperclass而不是直接采用协议(protocol)时,输出不是我所期望的。protocolTheProtocol{funcmethod1()}extensionTheProtocol{